开发者

Update query leaving a blank value

开发者 https://www.devze.com 2023-01-07 07:31 出处:网络
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 t

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");
0

精彩评论

暂无评论...
验证码 换一张
取 消