WilmotS Posted March 10, 2011 Share Posted March 10, 2011 I have been coding a new Dice Game for my website. Now on the owners control panel i have a function where they can send the dice. On that function i also want it to allow the owner to send the dice to "None" in which will drop the dice game. I have added that only everytime any name is put it into the giveto funtion the casino does as it has been set for when its sent to "none". Here is the code. ---------- if ($_POST['giveto']){ $giveto = $_POST['giveto']; $checkgiveto = mysql_query("SELECT username FROM users WHERE username='$giveto'"); $checkifexist = mysql_num_rows($checkgiveto); if($giveto = "none"){ mysql_query("UPDATE dice SET owner='None', maxbet='0', profit='0' WHERE country='$usercountry'"); echo "<font size=1 face=verdana color=white>This casino has been dropped!"; }else{ ---------- As you can see i have asked for that to happen when giveto is equal to "none". Only when anything is put there it still follows the code above and the casino drops. Anyone know what the problem is? Quote Link to comment https://forums.phpfreaks.com/topic/230211-problem-with-giveto/ Share on other sites More sharing options...
ManiacDan Posted March 10, 2011 Share Posted March 10, 2011 What do you mean "it follows the code above"? Do you mean that it executes code that you put on the page? Debug this yourself. Echo the value of $giveto. Echo your query. Don't just stare at the code and say "why isn't this working" out loud. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/230211-problem-with-giveto/#findComment-1185566 Share on other sites More sharing options...
WilmotS Posted March 10, 2011 Author Share Posted March 10, 2011 I have been looking for the problem and unable to find it. Hence the reason i have come to the forum. "giveto" is the name of the player they want to give the dice to. The code which i have showed you means if they send the dice to the name "none" then that code will be executed. Only if any name is typed into giveto such as Steven then it still does that code above. When that code should only be done if the giveto name is "none" Quote Link to comment https://forums.phpfreaks.com/topic/230211-problem-with-giveto/#findComment-1185569 Share on other sites More sharing options...
kenrbnsn Posted March 10, 2011 Share Posted March 10, 2011 In the "if" statement you are using a single "=", which is for assignment, instead of the double "==", which is for comparison, so the "if" is always "true", since the assignment always works. Change the "if" to <?php if($giveto == "none"){ ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/230211-problem-with-giveto/#findComment-1185576 Share on other sites More sharing options...
WilmotS Posted March 10, 2011 Author Share Posted March 10, 2011 Oh i see, works fine now, thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/230211-problem-with-giveto/#findComment-1185624 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.