dapcigar Posted October 29, 2014 Share Posted October 29, 2014 Am trying to save into the DB. after running the query, i keep getting this 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 'leave, meal, gross, tax, pension, dha, hmo, loan, surcharge, corporative, sa, ov' at line 1" have tried looking for the problem but i can't find it.. here's the code below $que = mysql_query("INSERT INTO salary(id, firstname, lastname, basic, housing, transport, ultility, entertainment, leave, meal, gross, tax, pension, dha, hmo, loan, surcharge, corporative, sa, overtime, netpay, date, status) VALUES (NULL, '$firstname', '$lastname', ' $basic', '$housing', '$transport', '$ultility', '$entertainment', '$leave', '$meal', '$gross', '$tax', '$pension', '$dha', '$hmo', '$loan', '$surcharge', '$corporative', '$sa', '$overtime', '$netpay', '$date', '$status')") or die(mysql_error()); Thanks in advance Link to comment https://forums.phpfreaks.com/topic/292143-sql-syntax-error/ Share on other sites More sharing options...
Barand Posted October 29, 2014 Share Posted October 29, 2014 'leave' is a MySQL reserved word. You need to enclose it in backticks (`leave`). NB - not single quotes. http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html Link to comment https://forums.phpfreaks.com/topic/292143-sql-syntax-error/#findComment-1495176 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.