Jump to content

SQL Syntax Error


Go to solution Solved by Barand,

Recommended Posts

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

  • Solution

'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

Edited by Barand
Link to comment
https://forums.phpfreaks.com/topic/292143-sql-syntax-error/#findComment-1495176
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.