Updating field in mysql database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
carbine
Forum Newbie
Posts: 6
Joined: Mon Mar 14, 2005 6:37 am

Updating field in mysql database

Post 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");
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

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