Page is a not externally linkable
- Code, Content, and Presentation
-- Databases
---- sql update statement mistake


snehula - 12:54 pm on Jun 14, 2011 (gmt 0)


$sql = " UPDATE persons SET fn = '".$_POST[firstname]."', sn ='".$_POST[surname]."', cmp = '".$_POST[company]."',";
$sql .=" addr1 = '".$_POST[addr1]."', addr2 = '".$_POST[addr2]."', addr3 = '".$_POST[addr3]."', county = '".$_POST[addr4]."', ";
$sql .=" hph = '".$_POST[phone1]."', wph = '".$_POST[phone2]."', mph1 = '".$_POST[phone3]."', mph2 = '".$_POST[phone4]."', ";
$sql .=" dateOfBirth = '".$dob."', cno = '".$_POST[sky_no]."', payment = '".$_POST[pnote]."', cstat= '".$_POST[cstatus]."', shutoff = '".$shutoff."',";


this is from a php script that sets the sql query (mysql), all post array values exist, + the variables were set before usage. I'm getting this mistake:

cannot execute query: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 '' at line 1


I have tried to execute the statement directly on the db with actual values, no problem there. I must be missing a quote or something but I really can't see it.. any ideas?


Thread source:: http://www.webmasterworld.com/databases_sql_mysql/4325891.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com