Jump to content
MakeWebGames

Error help


modernmafia

Recommended Posts

HELLO ITS ME AGAIN CHEERS FOR ALL PREVIOUS HELP GOT A NEW ONE FOR YOUR GUYS

HELP OR SUGGESTION FOR ME

CHEERS IN ADVANCE PLEASE REPLY TO THE TOPIC IF YOU CAN HELP AND NOT TO SLATE OTHERS ETC

 

HERE THE CODE :

<?
include "includes/game_connect.php";
$page_url = explode(".", $_SERVER['REQUEST_URI']);
$_SERVER['REQUEST_URI'] = $page_url[0].".php";

if($_SERVER['REQUEST_URI'] == "/_m_dice2.php"){
exit();
}

$username=$_SESSION['real_name'];
include "includes/game_connect.php";
$moneyzz=mysql_query("SELECT * FROM `users` WHERE `username`='$username'");
while($rowz = mysql_fetch_object($moneyzz)) { 


$_POST['fee'] =  ereg("[^0-9]",'',$_POST['fee']);
$_POST['fee'] = round($_POST['fee']);
$_POST['autoroll'] = ereg("[^0-9]",'',$_POST['autoroll']);
$_POST['autoroll'] = round($_POST['autoroll']);

if(isset($_POST['Create']) and empty($dice)){

if(empty($_POST['fee'])){
	echo "You must enter the starting fee.";
}else{

$check = mysql_query("SELECT * FROM multidice2 WHERE name='$username'");
$check2 = mysql_num_rows($check);

if ($check2 >=1){

echo "You can only have 1 multidice game at a time!";
}else{

$randid = rand(1,5000);
$minus = $_POST['fee'];
$autoroll = $_POST['autoroll'];
$feek = number_format($minus);
if($rowz->cash < $minus){
echo "You don't have enough cash to create this dice game.";
}else{

$result = mysql_query("UPDATE `users` SET `cash`=`cash`-'".mysql_real_escape_string($minus)."' WHERE `username`='$username'")or die(mysql_error());
$result= mysql_query("INSERT INTO `multidice2` (`player`,`price`,`name`,`diceid`,`diceno`,`autoroll`) VALUES ('".mysql_real_escape_string($username)."','".mysql_real_escape_string($_POST['fee'])."','$username','$randid','0','$autoroll')");
$result = mysql_query("INSERT INTO `mdice` (`id`,`playername`,`diceid`,`name`) VALUES ('','$username','$randid','$username')");
$result = mysql_query("INSERT INTO `logs` ( `id` , `who` , `action` , `date` , `ip` ) VALUES ('', '".mysql_real_escape_string($username)."', 'Created A Multidice For $$feek!', '$date', '$realip')");
echo "Your dice game has been created for $$feek.";
}
}
}
}
}
if(isset($_POST['Join'])){
$result = mysql_query("SELECT player,price,name,autoroll FROM multidice2 WHERE name='".mysql_real_escape_string($_POST['dice'])."' ORDER BY id DESC") or die(mysql_error());
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table

$mp_players = explode("-", $row['player']);
$mp_players = array_unique($mp_players);
$info_dice = explode("-", $row['price']);
$players = count($mp_players);
$autoroll = $row['autoroll'];

if($players >= $autoroll && $autoroll > 0){
echo "Sorry all spaces taken waiting on owner for autoroll.";
}
		else{

		if(empty($_POST['dice'])){
	echo "You didn't select a game.";
	}
	else{

$query = mysql_query("SELECT * FROM multidice2 WHERE name='".mysql_real_escape_string($_POST['dice'])."'") or die(mysql_error());
$row = mysql_fetch_object($query);
$rowwef = mysql_fetch_assoc($query);
$dice_info = htmlspecialchars($rowwef['player']);
$name = $_POST['dice'];

$sql1="SELECT * from multidice2 WHERE name='$name'";
$result1=mysql_query($sql1);

while($rows1=mysql_fetch_array($result1)){ // Start looping table row 

$player = $rows1['player'];
$diceid = $rows1['diceid'];
$price = $rows1['price'];
$diceno = $rows1['diceno'];
$name1 = $rows1['name'];
$autorollk = $rows1['autoroll'];
$diceno1 = $diceno + 1;
$priceof = number_format($price);
$add_name = $player."-".$username;
$mp_players = explode("-", $player);
$mp_players = array_unique($mp_players);
$mp_playersk = count($mp_players);




	if(in_array($username, $mp_players) or $username == $_POST['dice']){
		echo "You are already in this dice game.";
	}else{

	if($cash < $price){
			echo "You don't have enough cash to join this dice game.";
		}else{


$result = mysql_query("UPDATE `users` SET `cash`=`cash`-'$price' WHERE username='$username'") 
or die(mysql_error());

$result = mysql_query("UPDATE `multidice2` SET `player`='$add_name' WHERE name='" .mysql_real_escape_string($_POST['dice']). "'") 
or die(mysql_error());

$result = mysql_query("INSERT INTO `mdice` (`name`,`playername`,`diceid`) VALUES ('" .mysql_real_escape_string($_POST['dice']). "','$username','$diceid')");
			echo "You joined the dice game";
$result = mysql_query("INSERT INTO `logs` ( `id` , `who` , `action` , `date` , `ip` ) VALUES ('', '$username', 'Joined A Multidice With " .mysql_real_escape_string($_POST['dice']). " For $$priceof !', '$date', '$realip')");
}			

					}
				}
			}
		}
		}
		}
if(isset($_POST['Roll']) && $autoroll == 0){

$result = mysql_query("SELECT player,price,name,diceid FROM multidice2 WHERE name='$username' ORDER BY id DESC") or die(mysql_error());
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table

$mp_players = explode("-", $row['player']);
$mp_players = array_unique($mp_players);
$player = array_unique($mp_players);
$info_dice = explode("-", $row['price']);
$did = $row['diceid'];
$rk = array_rand($mp_players,1);
$winner = $mp_players[$rk];
$wina = $winner;


mysql_query("UPDATE `users` SET `cash`=`cash`+'".mysql_real_escape_string($info_dice[1] + ($info_dice[0] * count($mp_players)))."' WHERE username='$wina' LIMIT 1");

$sql="SELECT * from mdice WHERE name='$username' AND diceid='$did' ORDER by id ASC";
$result=mysql_query($sql);

while($rows=mysql_fetch_array($result)){ // Start looping table row 

$players=$rows['playername'];
$creater=$rows['name'];

mysql_query("INSERT INTO `messages` ( `id` , `t` , `f` , `message` , `date` , `r` , `saved` ) VALUES (
'', '$players', '$creater', '$creater rolled the dice <b>$wina</b> won and recieved <b>$".number_format($info_dice[1] + ($info_dice[0] * count($mp_players)))."</b>', '$date', '0', '0')");

mysql_query("UPDATE `users` SET `mail`='1' WHERE username='$players'");
mysql_query("INSERT INTO `logs` ( `id` , `who` , `action` , `date` , `ip` ) VALUES ('', '$username', '$creater rolled the dice <b>$wina</b> won and recieved <b>$".number_format($info_dice[1] + ($info_dice[0] * count($mp_players)))."</b>!', '$date', '$realip')");
}

echo "You rolled your dice <b>$wina</b> won! and recieved <b>$".number_format($info_dice[1] + ($info_dice[0] * count($mp_players)))."</b>";

mysql_query("DELETE FROM `multidice2` WHERE `name`='$username' LIMIT 1");

mysql_query("DELETE FROM `mdice` WHERE `name`='$username' LIMIT 1");
}
}


?>

 

 

THROWS THE FOLLOWING ERROR

Deprecated: Function ereg() is deprecated in /home/modernma/public_html/s2/mmoldneedwork/_m_dice2.php on line 16

Deprecated: Function ereg() is deprecated in /home/modernma/public_html/s2/mmoldneedwork/_m_dice2.php on line 18

WHEN PLACING A BET

I USE THIS SITE I WAS PREVIOUSLY GIVED BY ANOTHER MEMBER :http://php.net/manual/en/migration53.deprecated.php

IT SAYS TO REPLACE IT WITH preg_match

BUT WHEN I CHANGE TO PREG_MATCH I GET THIS ERROR : You must enter the starting fee.

 

ANY IDEAS

Link to comment
Share on other sites

preg_match() returns the number of times pattern matches. That will be either 0 times (no match) or 1 time because preg_match() will stop searching after the first match. preg_match_all() on the contrary will continue until it reaches the end of subject. preg_match() returns FALSE if an error occurred.

Therefore, I believe having the above;

$_POST['fee'] = preg_match("/[^0-9]/",'',$_POST['fee']);
$_POST['autoroll'] = preg_match("/[^0-9]/",'',$_POST['autoroll']);

Will overthrow the original value - what you _POST - to a numerical one - the amount of matches.

I'd suggest this approach, if what I've stated is correct.

if( preg_match("/[^0-9]/",",$_POST['fee']) ) {
// Return True (Not False)
} else {
// Return False (Not True // Integer)
}

if(  preg_match("/[^0-9]/",'',$_POST['autoroll']) ) {
// Return True (Not False)
} else {
// Return False (Not True // Integer)
}

 

Or adopt the concept you've chosen above, and assign them to variables.

$fee = preg_match("/[^0-9]/",'',$_POST['fee']);
$autoroll = preg_match("/[^0-9]/",'',$_POST['autoroll']);

if(!$fee OR !$autoroll) {
// Both False (Not True // Integer)
} else {
// Carry On
}

 

I haven't used preg_match much before, so this could be complete garbage...

Link to comment
Share on other sites

<?
include "includes/game_connect.php";
$page_url = explode(".", $_SERVER['REQUEST_URI']);
$_SERVER['REQUEST_URI'] = $page_url[0].".php";

if($_SERVER['REQUEST_URI'] == "/_m_dice2.php"){
exit();
}

$username=$_SESSION['real_name'];
include "includes/game_connect.php";
$moneyzz=mysql_query("SELECT * FROM `users` WHERE `username`='$username'");
while($rowz = mysql_fetch_object($moneyzz)) { 


$_POST['fee'] = preg_match("/[^0-9]/",'',$_POST['fee']);
$_POST['fee'] = round($_POST['fee']);
$_POST['autoroll'] = preg_match("/[^0-9]/",'',$_POST['autoroll']);
$_POST['autoroll'] = round($_POST['autoroll']);

if(isset($_POST['Create']) and empty($dice)){

if(empty($_POST['fee'])){
	echo "You must enter the starting fee.";
}else{

$check = mysql_query("SELECT * FROM multidice2 WHERE name='$username'");
$check2 = mysql_num_rows($check);

if ($check2 >=1){

echo "You can only have 1 multidice game at a time!";
}else{

$randid = rand(1,5000);
$minus = $_POST['fee'];
$autoroll = $_POST['autoroll'];
$feek = number_format($minus);
if($rowz->cash < $minus){
echo "You don't have enough cash to create this dice game.";
}else{

$result = mysql_query("UPDATE `users` SET `cash`=`cash`-'".mysql_real_escape_string($minus)."' WHERE `username`='$username'")or die(mysql_error());
$result= mysql_query("INSERT INTO `multidice2` (`player`,`price`,`name`,`diceid`,`diceno`,`autoroll`) VALUES ('".mysql_real_escape_string($username)."','".mysql_real_escape_string($_POST['fee'])."','$username','$randid','0','$autoroll')");
$result = mysql_query("INSERT INTO `mdice` (`id`,`playername`,`diceid`,`name`) VALUES ('','$username','$randid','$username')");
$result = mysql_query("INSERT INTO `logs` ( `id` , `who` , `action` , `date` , `ip` ) VALUES ('', '".mysql_real_escape_string($username)."', 'Created A Multidice For $$feek!', '$date', '$realip')");
echo "Your dice game has been created for $$feek.";
}
}
}
}
}
if(isset($_POST['Join'])){
$result = mysql_query("SELECT player,price,name,autoroll FROM multidice2 WHERE name='".mysql_real_escape_string($_POST['dice'])."' ORDER BY id DESC") or die(mysql_error());
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array($result)) {
// Print out the contents of each row into a table

$mp_players = explode("-", $row['player']);
$mp_players = array_unique($mp_players);
$info_dice = explode("-", $row['price']);
$players = count($mp_players);
$autoroll = $row['autoroll'];

if($players >= $autoroll && $autoroll > 0){
echo "Sorry all spaces taken waiting on owner for autoroll.";
}
		else{

		if(empty($_POST['dice'])){
	echo "You didn't select a game.";
	}
	else{

$query = mysql_query("SELECT * FROM multidice2 WHERE name='".mysql_real_escape_string($_POST['dice'])."'") or die(mysql_error());
$row = mysql_fetch_object($query);
$rowwef = mysql_fetch_assoc($query);
$dice_info = htmlspecialchars($rowwef['player']);
$name = $_POST['dice'];

$sql1="SELECT * from multidice2 WHERE name='$name'";
$result1=mysql_query($sql1);

while($rows1=mysql_fetch_array($result1)){ // Start looping table row 

$player = $rows1['player'];
$diceid = $rows1['diceid'];
$price = $rows1['price'];
$diceno = $rows1['diceno'];
$name1 = $rows1['name'];
$autorollk = $rows1['autoroll'];
$diceno1 = $diceno + 1;
$priceof = number_format($price);
$add_name = $player."-".$username;
$mp_players = explode("-", $player);
$mp_players = array_unique($mp_players);
$mp_playersk = count($mp_players);




	if(in_array($username, $mp_players) or $username == $_POST['dice']){
		echo "You are already in this dice game.";
	}else{

	if($cash < $price){
			echo "You don't have enough cash to join this dice game.";
		}else{


$result = mysql_query("UPDATE `users` SET `cash`=`cash`-'$price' WHERE username='$username'") 
or die(mysql_error());

$result = mysql_query("UPDATE `multidice2` SET `player`='$add_name' WHERE name='" .mysql_real_escape_string($_POST['dice']). "'") 
or die(mysql_error());

$result = mysql_query("INSERT INTO `mdice` (`name`,`playername`,`diceid`) VALUES ('" .mysql_real_escape_string($_POST['dice']). "','$username','$diceid')");
			echo "You joined the dice game";
$result = mysql_query("INSERT INTO `logs` ( `id` , `who` , `action` , `date` , `ip` ) VALUES ('', '$username', 'Joined A Multidice With " .mysql_real_escape_string($_POST['dice']). " For $$priceof !', '$date', '$realip')");
}			

					}
				}
			}
		}
		}
		}
if(isset($_POST['Roll']) && $autoroll == 0){

$result = mysql_query("SELECT player,price,name,diceid FROM multidice2 WHERE name='$username' ORDER BY id DESC") or die(mysql_error());
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table

$mp_players = explode("-", $row['player']);
$mp_players = array_unique($mp_players);
$player = array_unique($mp_players);
$info_dice = explode("-", $row['price']);
$did = $row['diceid'];
$rk = array_rand($mp_players,1);
$winner = $mp_players[$rk];
$wina = $winner;


mysql_query("UPDATE `users` SET `cash`=`cash`+'".mysql_real_escape_string($info_dice[1] + ($info_dice[0] * count($mp_players)))."' WHERE username='$wina' LIMIT 1");

$sql="SELECT * from mdice WHERE name='$username' AND diceid='$did' ORDER by id ASC";
$result=mysql_query($sql);

while($rows=mysql_fetch_array($result)){ // Start looping table row 

$players=$rows['playername'];
$creater=$rows['name'];

mysql_query("INSERT INTO `messages` ( `id` , `t` , `f` , `message` , `date` , `r` , `saved` ) VALUES (
'', '$players', '$creater', '$creater rolled the dice <b>$wina</b> won and recieved <b>$".number_format($info_dice[1] + ($info_dice[0] * count($mp_players)))."</b>', '$date', '0', '0')");

mysql_query("UPDATE `users` SET `mail`='1' WHERE username='$players'");
mysql_query("INSERT INTO `logs` ( `id` , `who` , `action` , `date` , `ip` ) VALUES ('', '$username', '$creater rolled the dice <b>$wina</b> won and recieved <b>$".number_format($info_dice[1] + ($info_dice[0] * count($mp_players)))."</b>!', '$date', '$realip')");
}

echo "You rolled your dice <b>$wina</b> won! and recieved <b>$".number_format($info_dice[1] + ($info_dice[0] * count($mp_players)))."</b>";

mysql_query("DELETE FROM `multidice2` WHERE `name`='$username' LIMIT 1");

mysql_query("DELETE FROM `mdice` WHERE `name`='$username' LIMIT 1");
}
}


?>

 

EDITED VERSION BUT WHEN I GO TO POST AN AMMOUNT IT SAYS You must enter the starting fee.

Link to comment
Share on other sites

I HAVE JUST POSTED BUT I DONT HINK IT WORKED SO THIS IS I WHAT I HAVE TRIED :

 

$_POST['fee'] = preg_match("/[^0-9]/",'',$_POST['fee']);

$_POST['fee'] = round($_POST['fee']);

$_POST['autoroll'] = preg_match("/[^0-9]/",'',$_POST['autoroll']);

$_POST['autoroll'] = round($_POST['autoroll']);

if(isset($_POST['Create']) and empty($dice)){

if(empty($_POST['fee'])){

echo "You must enter the starting fee.";

}else{

Link to comment
Share on other sites

You are setting $_POST[fee] to a boolean when you do

$_POST['fee']=preg_match(...);

 

Therefore if $_POST[fee] is not being posted or contains characters other than digits it will be false. Then you check to see if $_POST[fee] is empty. Which is basically like doing

if(empty(false))

... Which will have a result of false.

Actually there is a built in php function which does the exact same thing as your regex, except it is much better, performance wise.

You should be using something like this...

[noparse]$_POST['fee']=array_key_exists('fee',$_POST) && ctype_digit($_POST['fee']) ? round($_POST['fee']) : false;
$_POST['autoroll']=array_key_exists('autoroll',$_POST) && ctype_digit($_POST['autoroll']) ? round($_POST['autoroll']) : false;
if(array_key_exists('Create',$_POST) && empty($dice))
{
   if($_POST['fee']===false)
   {
       echo "You must enter a starting fee.";
   }
}[/noparse]

 

Also check to make sure the input element name in your form has the same casing as the key your are pulling in php. They must use the same case.

P.S. I don't know how you go about defining $dice or if $_POST[Create] is being submitted, but I put it in there assuming you are correctly handling them.

Link to comment
Share on other sites

Just look at my other reply, and refer to your reply when you do.

#1/

$_POST['fee'] = preg_match("/[^0-9]/",'',$_POST['fee']);

 

Therefore, I believe having the above;
$_POST['fee'] = preg_match("/[^0-9]/",'',$_POST['fee']);
$_POST['autoroll'] = preg_match("/[^0-9]/",'',$_POST['autoroll']);

 

Will overthrow the original value - what you _POST - to a numerical one - the amount of matches.

#2/

Refer to #1/

$_POST['autoroll'] = preg_match("/[^0-9]/",'',$_POST['autoroll']);
Link to comment
Share on other sites

maybe its late or maybe its me but i still cant seem to fix it

below is the main multi DICE screen

<?
session_start();  

if (!(isset($_SESSION["real_name"])))
{
//echo "I'm not logged in";
header('Location: index.php');
}
else
{
echo "";
}

?>



<html>
<head>
<title>game.com</title></head>
   	<link REL="stylesheet" TYPE="text/css" HREF="main.css">


<body background="wallpaper.jpg">
<center> 
<table border="0" cellspacing="0" cellpadding="0" align="center" width="95%" class="cat">

<TR> 

<TD width="150" background="tdbg3.jpg" bgcolor="#222222" valign="top">
<?php include("leftmenu.php");?>
</TD>
   <td width="100%" valign="top">	
   <br>	
   <? if ($userlevel == 2 || $userlevel == 3){
   echo "Entertainers can not view this page";
   }else{
   ?>
<form action="" method="post">
<table border="1" cellspacing="0" cellpadding="2" bordercolor="black" align="center" width="70%" class="sub2">

<tr>
<td align="center" class="header"><b>Multi Player Dice:</b></td></tr>
<tr><td align="center">Price :<br><input name="fee" type="text" class="entryfield" id="fee" style="border:0px; font-family:verdana; color:#CCC; background-color:#555; font-size:14px;" value="$"/>
<br>Auto Roll At:<br><input name="autoroll" type="text" class="entryfield" id="autoroll" style="border:0px; font-family:verdana; color:#CCC; background-color:#555; font-size:14px;" value="0"/></br><input name="Create" type="submit" class="button" id="Create" value="Create." onFocus="if(this.blur)this.blur()" /></td>
</tr>
 </table>
 <br>
 <table border="1" cellspacing="0" cellpadding="2" bordercolor="black" align="center" width="80%" class="sub2"> 
<?
include "includes/game_connect.php";
include "_m_dice2.php";	

$result = mysql_query("SELECT player,price,name,autoroll FROM multidice2 ORDER BY id DESC") or die(mysql_error());
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table

if(!empty($row['player'])){


$mp_players = explode("-", $row['player']);
$mp_players = array_unique($mp_players);
$info_dice = explode("-", $row['price']);
$players = count($mp_players);
$autoroll = $row['autoroll'];

?>
<br>
<div align="left">
<input name="dice" type="radio" value="<?php echo $row['name']; ?>" onFocus="if(this.blur)this.blur()"/>
<?php 
   $i = 1;
   foreach( $mp_players as $key => $value){
   echo " <a href=\"viewprofile.php?viewuser=". $value."\" onFocus=\"if(this.blur)this.blur()\">".$value."</a>";

    if($i != count($mp_players)) {
 echo "<font color=$layout><b> - </b></font>";
}
$i++;
} ?>
<?php echo " <b>Money Bet $".number_format($info_dice[0])." </b>"; ?>
<?php echo " <b><font color=grey> Total Money $".number_format($info_dice[1] + ($info_dice[0] * count($mp_players)))." </font></b>"; ?>
   <? if ($autoroll != 0){ ?><b>AutoRoll At <?php echo ($autoroll); ?> Players</b><? } ?>
<?
if($username == $row['name']){?>
<form method="post" action="">
     <input class="header" type="submit" name="Roll" value="Roll"> 
     <?php }?>
 <?php }}// while
// end print out results received.
?>
<br>
<form method="post" action="">
<input name="Join" type="Submit" class="header" id="Join" value="Join">
</table>
<br><br>
<?php if(empty($dice)){ ?>
<form action="" method="post">
<?php if($userlevel >= 10){ ?>
<center><a href="deadmdg.php"><font color=<? echo $layout ; ?>>*<b>Roll All Dead/Banned Players Multidices</b></font></a></center><? } ?> 
<?
				}}

?>

</td>



  	  <TD width="150" valign="top">
<?php include("rightmenu.php");?>
</TD>

</TR>


</table>

</center>
</body>
</html>

 

below is the second page multi dice is linked to

 

<?
include "includes/game_connect.php";
$page_url = explode(".", $_SERVER['REQUEST_URI']);
$_SERVER['REQUEST_URI'] = $page_url[0].".php";

if($_SERVER['REQUEST_URI'] == "/_m_dice2.php"){
exit();
}

$username=$_SESSION['real_name'];
include "includes/game_connect.php";
$moneyzz=mysql_query("SELECT * FROM `users` WHERE `username`='$username'");
while($rowz = mysql_fetch_object($moneyzz)) { 


$_POST['fee'] = ereg_replace("[^0-9]",'',$_POST['fee']);
$_POST['fee'] = round($_POST['fee']);
$_POST['autoroll'] = ereg_replace("[^0-9]",'',$_POST['autoroll']);
$_POST['autoroll'] = round($_POST['autoroll']);

if(isset($_POST['Create']) and empty($dice)){

if(empty($_POST['fee'])){
	echo "You must enter the starting fee.";
}else{

$check = mysql_query("SELECT * FROM multidice2 WHERE name='$username'");
$check2 = mysql_num_rows($check);

if ($check2 >=1){

echo "You can only have 1 multidice game at a time!";
}else{

$randid = rand(1,5000);
$minus = $_POST['fee'];
$autoroll = $_POST['autoroll'];
$feek = number_format($minus);
if($rowz->cash < $minus){
echo "You don't have enough cash to create this dice game.";
}else{

$result = mysql_query("UPDATE `users` SET `cash`=`cash`-'".mysql_real_escape_string($minus)."' WHERE `username`='$username'")or die(mysql_error());
$result= mysql_query("INSERT INTO `multidice2` (`player`,`price`,`name`,`diceid`,`diceno`,`autoroll`) VALUES ('".mysql_real_escape_string($username)."','".mysql_real_escape_string($_POST['fee'])."','$username','$randid','0','$autoroll')");
$result = mysql_query("INSERT INTO `mdice` (`id`,`playername`,`diceid`,`name`) VALUES ('','$username','$randid','$username')");
$result = mysql_query("INSERT INTO `logs` ( `id` , `who` , `action` , `date` , `ip` ) VALUES ('', '".mysql_real_escape_string($username)."', 'Created A Multidice For $$feek!', '$date', '$realip')");
echo "Your dice game has been created for $$feek.";
}
}
}
}
}
if(isset($_POST['Join'])){
$result = mysql_query("SELECT player,price,name,autoroll FROM multidice2 WHERE name='".mysql_real_escape_string($_POST['dice'])."' ORDER BY id DESC") or die(mysql_error());
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table

$mp_players = explode("-", $row['player']);
$mp_players = array_unique($mp_players);
$info_dice = explode("-", $row['price']);
$players = count($mp_players);
$autoroll = $row['autoroll'];

if($players >= $autoroll && $autoroll > 0){
echo "Sorry all spaces taken waiting on owner for autoroll.";
}
		else{

		if(empty($_POST['dice'])){
	echo "You didn't select a game.";
	}
	else{

$query = mysql_query("SELECT * FROM multidice2 WHERE name='".mysql_real_escape_string($_POST['dice'])."'") or die(mysql_error());
$row = mysql_fetch_object($query);
$rowwef = mysql_fetch_assoc($query);
$dice_info = htmlspecialchars($rowwef['player']);
$name = $_POST['dice'];

$sql1="SELECT * from multidice2 WHERE name='$name'";
$result1=mysql_query($sql1);

while($rows1=mysql_fetch_array($result1)){ // Start looping table row 

$player = $rows1['player'];
$diceid = $rows1['diceid'];
$price = $rows1['price'];
$diceno = $rows1['diceno'];
$name1 = $rows1['name'];
$autorollk = $rows1['autoroll'];
$diceno1 = $diceno + 1;
$priceof = number_format($price);
$add_name = $player."-".$username;
$mp_players = explode("-", $player);
$mp_players = array_unique($mp_players);
$mp_playersk = count($mp_players);




	if(in_array($username, $mp_players) or $username == $_POST['dice']){
		echo "You are already in this dice game.";
	}else{

	if($cash < $price){
			echo "You don't have enough cash to join this dice game.";
		}else{


$result = mysql_query("UPDATE `users` SET `cash`=`cash`-'$price' WHERE username='$username'") 
or die(mysql_error());

$result = mysql_query("UPDATE `multidice2` SET `player`='$add_name' WHERE name='" .mysql_real_escape_string($_POST['dice']). "'") 
or die(mysql_error());

$result = mysql_query("INSERT INTO `mdice` (`name`,`playername`,`diceid`) VALUES ('" .mysql_real_escape_string($_POST['dice']). "','$username','$diceid')");
			echo "You joined the dice game";
$result = mysql_query("INSERT INTO `logs` ( `id` , `who` , `action` , `date` , `ip` ) VALUES ('', '$username', 'Joined A Multidice With " .mysql_real_escape_string($_POST['dice']). " For $$priceof !', '$date', '$realip')");
}			

					}
				}
			}
		}
		}
		}
if(isset($_POST['Roll']) && $autoroll == 0){

$result = mysql_query("SELECT player,price,name,diceid FROM multidice2 WHERE name='$username' ORDER BY id DESC") or die(mysql_error());
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table

$mp_players = explode("-", $row['player']);
$mp_players = array_unique($mp_players);
$player = array_unique($mp_players);
$info_dice = explode("-", $row['price']);
$did = $row['diceid'];
$rk = array_rand($mp_players,1);
$winner = $mp_players[$rk];
$wina = $winner;


mysql_query("UPDATE `users` SET `cash`=`cash`+'".mysql_real_escape_string($info_dice[1] + ($info_dice[0] * count($mp_players)))."' WHERE username='$wina' LIMIT 1");

$sql="SELECT * from mdice WHERE name='$username' AND diceid='$did' ORDER by id ASC";
$result=mysql_query($sql);

while($rows=mysql_fetch_array($result)){ // Start looping table row 

$players=$rows['playername'];
$creater=$rows['name'];

mysql_query("INSERT INTO `messages` ( `id` , `t` , `f` , `message` , `date` , `r` , `saved` ) VALUES (
'', '$players', '$creater', '$creater rolled the dice <b>$wina</b> won and recieved <b>$".number_format($info_dice[1] + ($info_dice[0] * count($mp_players)))."</b>', '$date', '0', '0')");

mysql_query("UPDATE `users` SET `mail`='1' WHERE username='$players'");
mysql_query("INSERT INTO `logs` ( `id` , `who` , `action` , `date` , `ip` ) VALUES ('', '$username', '$creater rolled the dice <b>$wina</b> won and recieved <b>$".number_format($info_dice[1] + ($info_dice[0] * count($mp_players)))."</b>!', '$date', '$realip')");
}

echo "You rolled your dice <b>$wina</b> won! and recieved <b>$".number_format($info_dice[1] + ($info_dice[0] * count($mp_players)))."</b>";

mysql_query("DELETE FROM `multidice2` WHERE `name`='$username' LIMIT 1");

mysql_query("DELETE FROM `mdice` WHERE `name`='$username' LIMIT 1");
}
}


?>

 

P.S THESE ARE TWO NO EDITED VERSION I HAVE TRIED A FEW TIME IF ANY BODY CAN POST THE WHOLE SNIPPET/THERE EDITED VERSION SO I CAN TRY IT PLEASE DO I WONT REPLY TO THIS NOW TILL TOMMORROW AS I HAVE WORK AT 9 TILL 6

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...