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!

Recommended Answers

All 3 Replies

Member Avatar for 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!

Member Avatar for diafol

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.