-
create table...
I'm trying to create a script that will make a table with an id that auto increments, here's what i've got, but it seems to be broke...
PHP Code:
$sql2 = "CREATE TABLE ns_names PRIMARY KEY(id)(
name VARCHAR (50),
email VARCHAR (50),
timestamp TIMESTAMP,
id INTEGER NOT NULL AUTO_INCREMENT
);";
I'm trying to make 'id' primary, not null, and auto_incrementing, but it won't work...any idea on how to fix this?
-
PRIMARY KEY needs to be inside the create statement. preferrably on the same lin as the id definition.
PHP Code:
$sql2 = "CREATE TABLE ns_names (
name VARCHAR(50),
email VARCHAR(50),
timestamp TIMESTAMP,
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
)";
Although I think this will work also.
PHP Code:
$sql2 = "CREATE TABLE ns_names (
name VARCHAR(50),
email VARCHAR(50),
timestamp TIMESTAMP,
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id)
)";
-