John
John

Reputation: 4944

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. 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

Answers (3)

gblazex
gblazex

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

Zuul
Zuul

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

GSto
GSto

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

Related Questions