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);
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);
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?
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.
$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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.