Reputation: 4944
I'm trying to overwrite data in a MySQL table called "login." I want to replace a field called "website" with the variable $cleanURL. The 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'");
Upvotes: 1
Views: 123
Reputation: 50109
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");
Upvotes: 1
Reputation: 16269
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!
Upvotes: 1
Reputation: 42350
you didn't quote the $cleanURL variable, or possibly the $uid variable is incorrect.
mysql_query("Update login SET website = '$cleanURL' WHERE loginid = '$uid'");
Upvotes: 2