Jump to content

Recommended Posts

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?

 

Link to comment
https://forums.phpfreaks.com/topic/230211-problem-with-giveto/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/230211-problem-with-giveto/#findComment-1185566
Share on other sites

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"

 

Link to comment
https://forums.phpfreaks.com/topic/230211-problem-with-giveto/#findComment-1185569
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/230211-problem-with-giveto/#findComment-1185576
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.