0

I am adding comments to a website and thought I would make a simple comments table as follows but it is not working. Must be a typo but I cannot find it despite going over and over it and copying it into a different file and so forth. Also for those familiar with comments are these an adequate number of fields?

$maketable = "CREATE TABLE comments(id INT NOT NULL AUTO_INCREMENT, 
 PRIMARY KEY(id),
 name VARCHAR(30),
 whenadded DATETIME,
 storyid INT,
 comment TEXT,
 show TINYINT(1),
 userid INT)";
mysql_query($maketable);

4 Answers 4

2

I think 'show' is a reserved word in mysql. Try 'display' or something else:

$maketable = "CREATE TABLE comments(id INT NOT NULL AUTO_INCREMENT, 
 PRIMARY KEY(id),
 name VARCHAR(30),
 whenadded DATETIME,
 storyid INT,
 comment TEXT,
 display TINYINT(1),
 userid INT)";
mysql_query($maketable);
Sign up to request clarification or add additional context in comments.

Comments

0

The credentials you are using for your database connection pooling in php should not have create/drop privileges on your database. It is better to use a "sql-tool" like phpmyadmin to do your database design.

One off the advantages are better error messages for debugging purposes?

2 Comments

How do you disable create/drop in connection string? I do have phpadmin which I am using to look at dbase.
You do not disable this in your connection string. You need to change the your database user permissions.
0
$maketable ="CREATE TABLE  comments (
id INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
name VARCHAR( 30 ) NOT NULL,
whenadded DATETIME,
storyid INT( 10 ),
 comment TEXT,
 display INT(1),
 userid INT ( 10 )
) ENGINE = MYISAM;"
mysql_query($maketable);

Comments

0

have you checked mysql_error?

php.net/mysql_error

and i would move the PRIMARY KEY line to the very bottom of the sql statement.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.