Update query leaving a blank value
I'm trying to overwrite data in a MySQL table called "login." I want to replace a field called "website" with the variable $cleanURL. Th开发者_StackOverflow中文版e code below is what I have tried to use, but the field just ends up blank / empty after I try to use it.
Any idea why this is happening?
mysql_query("Update login
SET website = $cleanURL
WHERE loginid = '$uid'");
you didn't quote the $cleanURL variable, or possibly the $uid variable is incorrect.
mysql_query("Update login SET website = '$cleanURL' WHERE loginid = '$uid'");
Missing quotes:
try:
mysql_query("Update login SET website = '$cleanURL' WHERE loginid = '$uid'");
or:
mysql_query("Update login SET website = '".$cleanURL."' WHERE loginid = '".$uid."'");
Hope it helps!
You forgot to quote $cleanURL
which is a string
. ($uid
on the other hand is not necessary to be quoted because it is an integer
)
mysql_query("UPDATE login SET website = '$cleanURL' WHERE loginid = $uid");
精彩评论