I'm working on a script which needs to update records within a MySQL db, here is the code I have and the error it generates. This is giving me a huge headache so I hope someone here can see what I'm missing:
$cid = mysql_connect($host,$usr,$pwd);
$SQL = " UPDATE friends SET";
$SQL = $SQL . " fname = '$fname', ";
$SQL = $SQL . " mname = '$mname', ";
$SQL = $SQL . " lname = '$lname', ";
$SQL = $SQL . " WHERE id = $id ";
$result = mysql_db_query($db,"$SQL",$cid);
ERROR: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = 3' at line 1 UPDATE friends SET fname = 'John', mname = 'T', lname = 'Doe', WHERE id = 3
I'm using MySQL version 4.0.15, and from what I can find the PHP code seems correct though it obviously isn't.
Thanks in advance for any ideas or suggestions,
Scott