Hello all,
I am currently trying to insert a 0 value into a single field. The value is originally set to 1 and I would like to set it to its default value of 0. How would I go about doing that?
The code I have works for other things, but I simply want to change the field of online1 to 0 in the database table. This is what I have:

            mysql_query("UPDATE `users` SET `online1` = 0  WHERE `id` = '".$_SESSION['uid']."' ");

Thanks for the help!

5 Years
Discussion Span
Last Post by diafol

Looks OK.

mysql_query("UPDATE `users` SET `online1` = 0  WHERE `id` = {$_SESSION['uid']}");

Assuming both online1 and id are integer fields. echo out the query to see if it matches your expectation.

echo "UPDATE `users` SET `online1` = 0  WHERE `id` = {$_SESSION['uid']}";

I did what you said and there was an error. After fiddling around for a bit, I finally found the error. Thanks for your help! I appreciate it!


OK, perhaps if you post your fix, it may help others with similar issues?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.