简体   繁体   中英

MySQL and PHP table not being created

HELP! Code not creating a table, does this look ok? How do you usually debug to find out what is not working in MySQL?

<?php  
// Connect to the file above here  
require "connect_to_mysql.php"; 

$sqlCommand = "CREATE TABLE products (
id INT(11) NOT NULL auto_increment,
product_name VARCHAR(255) NOT NULL,
price VARCHAR(64) NOT NULL, 
details text NOT NULL,
category varchar(64) NOT NULL,
date_added date NOT NULL,
PRIMARY KEY(id),
UNIQUE KEY product_name(product_name),
)";

mysql_query($sqlCommand) or die(mysql_error());
?>

The last line doesn't need a comma ,

$sqlCommand = "CREATE TABLE products (
id INT(11) NOT NULL auto_increment,
product_name VARCHAR(255) NOT NULL,
price VARCHAR(64) NOT NULL, 
details text NOT NULL,
category varchar(64) NOT NULL,
date_added date NOT NULL,
PRIMARY KEY(id),
UNIQUE KEY product_name(product_name)
)";

I tried out this code in phpMyAdmin first and found that error ^

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM