SQL syntax problems...?

<?php

$selected_db='naughty';

$username=$_POST['username'];

$offence=$_POST['offence'];

$punishment= $_POST['punishment'];

$con=mysql_connect('localhost','root','panda')or die (mysql_error());

include 'error.php';

include 'database.php';

if (!$con)

{

die('could not connect: ' . mysql_error());

}

mysql_select_db("naughtylist") or die(mysql_error());

mysql_query ("CREATE TABLE watchlist

username VARCHAR(16) NOT NULL,

offence TEXT NOT NULL,

punishment TEXT NOT NULL,

PRIMARY KEY (username)

")

or die (mysql_error());

$result=mysql_query($query);

if (!$result) {

$message = 'Invalid query: ' . mysql_error() . "\n";

$message .= 'Whole query: ' . $query;

die($message);

}

?>

I am getting an error for this code, with the error concerning the syntax at:

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 'username VARCHAR(16) NOT NULL, offence TEXT NOT NULL, punishment TEXT NOT NULL' at line 2

Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Helpful Social

Copyright © 2024 Q2A.ES - All rights reserved.