Problem in inserting query in database

Reply

Join Date: Feb 2009
Posts: 130
Reputation: gagan22 is an unknown quantity at this point 
Solved Threads: 0
gagan22 gagan22 is offline Offline
Junior Poster

Problem in inserting query in database

 
0
  #1
Mar 26th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 883
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 142
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark

Re: Problem in inserting query in database

 
0
  #2
Mar 26th, 2009
leave is a mysql statement. try putting backticks around it.
  1. $sqlquery = "insert into `leave` (session_id,empid,`leave`,year) values('$_SESSION[id]', '$_SESSION[empid]', '$_POST[leavenum]', '$_POST[year]')";
  2. $res = mysql_query($sqlquery,$link) OR die('Error: ' . mysql_error());
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 292 | Replies: 1
Thread Tools Search this Thread



Tag cloud for MySQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC