Pranav Kumar Pranav Kumar - 6 months ago 9
PHP Question

PHP - inserting values error: Check SQL version

I have tried to insert a few values but it doesn't work. It show an 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 '','pranavkumar.chess@gmail.com')' at line 1


I need to do something about it. So, can you help please.

The portion PHP Code is:

$reason= $_GET['reason'];
$option= $_GET['option'];
$for= $_GET['category'];
$approved= $_GET['approved'];
$before= $_GET['before'];
$username= $_SESSION ["username"];
$myquery="INSERT INTO request (`serial number`, `request date`, `request for category`, `request`, `reason`, `approved by`, `username`) VALUES ('',NOW(),'$for','$option','$reason',$approved','$username')";
$query = mysql_query($myquery);

if ( ! $query ) {
echo mysql_error();
die;
}


Please help. Upvote this question if it helped.

Answer

Single Quote missing @ '$approved'

     $myquery="INSERT INTO request (`serial number`, `request date`, `request for category`, `request`, `reason`, `approved by`, `username`) VALUES  ('',NOW(),'$for','$option','$reason','$approved','$username')";
Comments