Click to See Complete Forum and Search --> : mysql edit info by id


marcusami
05-06-2008, 01:09 PM
hey im pretty new at mysql but i have got a site going that you post info on and it is recorded in the database

but now i am trying to edit it from a webpage

i can call up the info so its displayed and ready to be edited, but I cant save the edit to the same id

when i do


mysql_query("INSERT INTO trailers
(t_Name, t_Price, t_Loc, t_Desc, t_Loc_a, t_Loc_b, t_File) VALUES('$theName', '$thePrice', '$theTarget', '$theDesc', '$theTarget_a', '$theTarget_b', '$aFileName') WHERE id = '$hold_Id' ")
or die(mysql_error());


i get a error of

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 = '193'' at line 2

TJ111
05-06-2008, 01:16 PM
Use the UPDATE syntax (http://dev.mysql.com/doc/refman/5.0/en/update.html).

UPDATE trailers SET t_Name = '$theName', t_Price = '$thePrice' ... WHERE id = $hold_ID;

marcusami
05-06-2008, 01:37 PM
second time youve saved me today! thanks!

regards
Marcus