My CREATE TABLE doesn't work!

Hi,

The code below runs, does nothing and the system gives the message following the code. Can anybody tell me what I’m missing?

Thanks,

Mike

$query = "
CREATE TABLE keywordstab
(
keyword VARCHAR(25) NOT NULL,
booknr INT (6) NOT NULL,
PRIMARY KEY(keyword)
)";

#1064 - 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 ‘$query = " CREATE TABLE keywordstab ( keyword VARCHAR(25) NOT NUL’ at line 1”

Try it directly in the mysql client, works fine for me. You may have introduced an error on php end.

Hi,
Thanks for your reply but I don’t understand what you mean by

.
Could you give me more info.
You mentioned a php error, here’s the complete program.

Mike
<?php
include(“misc.inc”);

$connection = mysql_connect($host,$user,$password)
or die (“No connection”);
$db = mysql_select_db($database,$connection)
or die (“No selection”);
$query = "
CREATE TABLE keywordstab
(
keyword VARCHAR(25) NOT NULL,
booknr INT (6) NOT NULL,
PRIMARY KEY(keyword)
)";
?>

You didn’t execute the query


<?php
include("misc.inc");

$connection = mysql_connect($host,$user,$password)
or die ("No connection");
$db = mysql_select_db($database,$connection)
or die ("No selection");
$query = "
CREATE TABLE keywordstab
(
keyword VARCHAR(25) NOT NULL,
booknr INT (6) NOT NULL,
PRIMARY KEY(keyword)
)";
mysql_query($query, $db);
?>

(note the mysql_query($query, $db); at the end).

ScallioXTX,

I changed the mysql_query statement slightly to

$result = mysql_query($query, $connection);

And it worked

Thanks for your quick help.

Mike