Page 1 of 1

Updating field in mysql database

Posted: Tue Mar 15, 2005 9:58 am
by carbine
Trying to update my database using the following line of code, though nothing seems to be happening. Any suggestions as to why not? Thanks

Code: Select all

$userid="cs";
$sql=mysql_query("UPDATE test SET forename = 'Micko' WHERE userid = $userid");

Posted: Tue Mar 15, 2005 10:01 am
by CoderGoblin
Include debugging information into your script and you should find it easier to track down problems like this.... :wink:

Code: Select all

$userid="cs";
$sql=mysql_query("UPDATE test SET forename = 'Micko' WHERE userid = '$userid'");
$userid is a string so SQL needs single quotes around it.