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

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());
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.