shorty3 Posted June 15, 2009 Share Posted June 15, 2009 I can`t understand why people can still win on a number below 10 and can lose with being more than 10. <?php session_start(); logincheck(); $username=$_SESSION['username']; include_once"casinoCP.php"; $it = 'Dice'; casinocp($it); $crimes = mysql_query("SELECT money,location FROM users WHERE username='$username'"); while($success = mysql_fetch_row($crimes)){ $money = $success[0]; $location = $success[1]; } $crimes1 = mysql_query("SELECT owner,max FROM casinos WHERE location='$location' AND casino='Dice'"); while($success1 = mysql_fetch_row($crimes1)){ $owner = $success1[0]; $max = $success1[1]; $min = $success1[2]; } $crimes3 = mysql_query("SELECT money FROM users WHERE username='$owner'"); while($success3 = mysql_fetch_row($crimes3)){ $money1 = $success3[0]; } $bet = $_POST['bet']; $bet=strip_tags($bet); if ($_POST['Submit']){ echo "$bet"; if ($bet > $max){ echo "Your bet exceeds the set max bet."; }elseif ($bet <= $max){ if ($bet > $money){ echo "You dont have that much money."; }elseif($bet <= $money){ if (ereg('[^0-9]',$bet)) { echo "Invalid Numbers!"; }elseif (!ereg('[^0-9]',$bet)){ if ($bet < '0') { echo "Error."; }elseif ($bet > 0){ $dice = rand(1,6); $dice2 = rand(1,6); $imgsrc = "dice/$dice.jpg"; $imgsrc1 = "dice/$dice2.jpg"; if ($dice + $dice2 < 10){ echo "Unlucky you lost £$bet."; $cmoney = $money1 + $bet; $fuck = $money - $bet; $er = $earnings + $bet; mysql_query("UPDATE casinos SET profit='$er' WHERE location='$fetch->location' AND casino='Dice'"); mysql_query("UPDATE users SET money='$fuck' WHERE username='$username'"); mysql_query("UPDATE users SET money='$cmoney' WHERE username='$owner'"); }elseif ($dice + $dice2 >= 10){ $hahaa = $bet * 4; if ($hahaa > $money1){ $ownersmoney = $money1; $lost = 1; }elseif ($hahaa <= $money1){ $ownersmoney = $money1 - $hahaa; $lost = 0; } if ($lost == '1'){ ////CASINO OWNER GOES BROKE???//// echo "The casino owner went broke!"; mysql_query("UPDATE casinos SET owner='0' WHERE casino='Dice' AND location='$fetch->location'"); mysql_query("UPDATE users SET money='0' WHERE username='$owner'"); echo "<br> You did not loose any money."; ////????OR MAYBE NOT????//// }elseif ($lost == '0'){ $hahaa = $bet * 4; $ownersmoney = $money1 - ($bet * 4); $winermoney = $money + ($bet * 4); mysql_query("UPDATE users SET money='$ownersmoney' WHERE username='$owner'"); mysql_query("UPDATE users SET money='$winermoney' WHERE username='$username'"); $er = $money1 - ($bet * 4); ///update casino earnings/// mysql_query("UPDATE casinos SET profit='$er' WHERE location='$location' AND casino='Dice' AND owner !=''"); echo "Congratulations you won!! $".makecomma($hahaa).""; ///Update the casino earnings ////just help// } }}}}}} ?> <html> <link rel="stylesheet" href="includes/in.css" type="text/css"> <script language="JavaScript"> function disableEnterKey() { if (window.event.keyCode == 13) window.event.keyCode = 0; } </script> <link href="../../My Received Files/tmn cloned/includes/in.css" rel="stylesheet" type="text/css"> <table width=25% height="81" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#000000" class="thinline"> <tr> <td height="20" align=center background=includes/grad.jpg>You Rolled </td> </tr> <tr><td> <center> <br> <img src="<?php if ($imgsrc == ""){ echo "dice/1.jpg"; }else{ echo "$imgsrc"; } ?>"> <img src="<?php if ($imgsrc == ""){ echo "dice/1.jpg"; }else{ echo "$imgsrc"; } ?>"> <br> <br> </center></td> </tr> <tr> <td><div align="center"><span class="style2">To win you must role 10 or more on 2 dice, If you role 10 or more you will win 4x the amount you bet. </span></div></td> </tr> </table> <br> <form action='' method=post onKeyPress="disableEnterKey()"><table width=25% align="center" cellpadding=0 cellspacing=0> <tr valign=top><td width=50% align="center"><br> <table width="100%" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#000000" class="thinline"> <tr> <td height="20" align="center" background="includes/grad.jpg" scope="col">Roll The Dice </td> </tr> <tr> <td align="center" bgcolor="#737373"> <p>Place Your Bets:<br> <br> <input name="bet" type=text class="text_box"> </p> <p> <input name = 'Submit' type=submit class="abutton" value="Roll"> </p></td> </tr> </table> <br> <span class="style2">This Dice Game is Owned By <?php if ($owner !=""){ echo "<a href='profile.php?viewuser=$owner'><b>$owner</b></a>"; }elseif ($owner == ""){ echo "<u><b>No one</u></b>"; } ?> <br> The max bet is set at <?php echo "$".makecomma($max).""; ?></span> </td> </tr> </table></form> Theres the code im using if you want to see it in action so you`ve got a better picture of what it does then log onto http://streetracerz.ulmb.com/authenticated.php username:bullet2 password: demo I Also Cant understand why when you win or lose theres a number1 one before the message example: 1Congratulations you won!! $4 - 1Unlucky you lost $1. EDIT: I've added code tags for you. Please try not to post raw code as raw text. It's extremely tedious (if not already) to read all that. You're more apt to get help if you use them too. Quote Link to comment https://forums.phpfreaks.com/topic/162206-help-with-php-script-dice/ Share on other sites More sharing options...
Zane Posted June 15, 2009 Share Posted June 15, 2009 I can't exactly understand your question. If I have to play blackjack or something to figure it out then...I've given up. Explain in steps what you're doing to produce this error and you'll get better answers. Quote Link to comment https://forums.phpfreaks.com/topic/162206-help-with-php-script-dice/#findComment-856029 Share on other sites More sharing options...
tommyboy123x Posted June 15, 2009 Share Posted June 15, 2009 It would definitely start by naming variables what they should be. I've noticed that it makes things a lot harder once you look back at old code or even when you are debugging. I'm with zanus on this one. Can you explain a bit more of what is going on / what the script does? There must be more than 1 file, right? Quote Link to comment https://forums.phpfreaks.com/topic/162206-help-with-php-script-dice/#findComment-856038 Share on other sites More sharing options...
shorty3 Posted June 15, 2009 Author Share Posted June 15, 2009 The only way to see the error is to play it(Dice). You will not have to pay to play it because its a free game. And dice is a simple game. I have looked at the code and can`t see nothing wrong im sure it will be something minor. If you having problems finding dice log on and scroll the left side bar down to the casino section and click on dice place bets of $1 until you see the problem. if you don`t understand post a reply and i will try to explain further. Thank You! Quote Link to comment https://forums.phpfreaks.com/topic/162206-help-with-php-script-dice/#findComment-856041 Share on other sites More sharing options...
shorty3 Posted June 15, 2009 Author Share Posted June 15, 2009 Just not to confuse any one. When i say bet $1 i mean game money not real money. You will NOT be spending you own money to see the error i can safely say that. Quote Link to comment https://forums.phpfreaks.com/topic/162206-help-with-php-script-dice/#findComment-856043 Share on other sites More sharing options...
Zane Posted June 15, 2009 Share Posted June 15, 2009 Ok, so I went and played the game and the only question I can think of is Did you make this yourself? If you wrote this program yourself you should obviously know that it's just a few unwanted echo's The one in front of Congradulations is from this line if ($_POST['Submit']){ echo "$bet"; if ($bet > $max){ echo "Your bet exceeds the set max bet."; I played the game and all it was doing "odd" was putting my placed bet before the message 900Congratulations you won!! $3,600 1Congratulations you won!! $4 198Unlucky you lost £198. One thing I can't understand is why when you loose..it's scripted to say pounds..you oughta fix that. if ($dice + $dice2 echo "Unlucky you lost £$bet."; Quote Link to comment https://forums.phpfreaks.com/topic/162206-help-with-php-script-dice/#findComment-856046 Share on other sites More sharing options...
shorty3 Posted June 15, 2009 Author Share Posted June 15, 2009 Thanks for solving that problem. But thats just part of the problem the rules of the game are "To win you must role 10 or more on 2 dice, If you role 10 or more you will win 4x the amount you bet." but some times people have been rolling two sixs or two fives and it says unlucky you lost x amount when they shud be winning and ive rolled two fours and won. But on the over hand some times its correct and works smoothly. Thank You! P.s Thanks for spotting the £ i am currntly changing currency from pound to dollar as im hoping for more american players Quote Link to comment https://forums.phpfreaks.com/topic/162206-help-with-php-script-dice/#findComment-856047 Share on other sites More sharing options...
Zane Posted June 15, 2009 Share Posted June 15, 2009 Now that's the kind of explanation I was looking for. Although I don't exactly know the solution off the top of my head, but....to be honest....you have way too many variables and IFs for me to figure this one out. You need to go through your script (maybe even rewrite it) and follow it's procedure. Then you'll surely come across your error Quote Link to comment https://forums.phpfreaks.com/topic/162206-help-with-php-script-dice/#findComment-856051 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.