0

Hi everyone,

I am inserting value in a table in a database through query but it is giving some error as like 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 (session_id,empid,leave,year) values('20202', 'DTL0009', '21', '2009')' at line 1


and the code for inserting these value is as i writing this code:-

$sqlquery = "insert into leave (session_id,empid,leave,year) values('$_SESSION[id]', '$_SESSION[empid]', '$_POST[leavenum]', '$_POST[year]')";
	$res = mysql_query($sqlquery,$link) or die('Error: ' . mysql_error());

But i am receiving this error. I am unable to insert records in database. Please help me. How i can sort out this problem.
Thanks,
Gagan

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by pritaeas
0

leave is a mysql statement. try putting backticks around it.

$sqlquery = "insert into `leave` (session_id,empid,`leave`,year) values('$_SESSION[id]', '$_SESSION[empid]', '$_POST[leavenum]', '$_POST[year]')";
$res = mysql_query($sqlquery,$link) or die('Error: ' . mysql_error());
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.