문제

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 ^

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top