Code:
<?php
require ('config.php');
$username=$_POST['username'];
$offence=$_POST['offence'];
$punishment= $_POST['punishment'];
$table=naughty;
$con= @mysql_connect ($dbhost,$dbusername,$dbpassword); //used to conneect to the mysql database
if (!$con)
{
die ('could not connect: ' .mysql_error());
}
$sql="SELECT*FROM $table";
$result=mysql_query($sql);
if (!result)
{
echo "No table exists!";
exit ();
}
@mysql_select_db("naughtylist", $con);
$sql="CREATE TABLE `naughtylist`.`naughty` (
`username` VARCHAR(15) NOT NULL,
`offence` VARCHAR(45) NOT NULL,
`punishment` VARCHAR(45) NOT NULL,
PRIMARY KEY (`username`)
)";
$query=mysql_query ("INSERT INTO naughty (username, offence, punishment) VALUES ('$username','$offence', '$punishment')");
$result=mysql_query($query) or die (mysql_error());
?>
The error is not helpful at all:
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 '1' at line 1..