Hi experts,
I have this code to add records to MySQL database in a table named main, getting the following error, please help:
[QUOTE]
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 ‘,)’ at line 1
INSERT INTO main (class,subject,chapter) VALUES (,,)Record Added
[code=php]<?php
$con = mysql_connect(“localhost”,”root”,””);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}
mysql_select_db(“quiz”, $con);
$class=””;
$subject=””;
$chapter=””;
extract($_POST);
$sql=”INSERT INTO main (class,subject,chapter) VALUES ($class,$subject,$chapter)”;
// Execute query
if(mysql_query($sql,$con) === false)
{
echo mysql_error() . “<br />$sql”;
}
mysql_close($con);
print “Record Added”;
?>
Thanks in advance.