tags:

views:

51

answers:

1

I'm trying to create a simple database table using the PHP MySQL Querry "Create Table", but it's not working.

What is wrong with the below code?

 // Make a MySQL Connection
mysql_connect("localhost","the_database_name","the_database_password") or die(mysql_error());
mysql_select_db("the_database_name") or die(mysql_error());

// Create a MySQL table in the selected database
mysql_query("CREATE TABLE downloads_list(
download_id INT(7) UNSIGNED NOT NULL AUTO_INCREMENT,
download_date TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
visitor_first_name VARCHAR(20) NOT NULL,
visitor_last_name VARCHAR(20) NOT NULL,
visitor_email VARCHAR(50) NOT NULL,
visitor_phone VARCHAR(30) NOT NULL,
store_name VARCHAR(20) NOT NULL,
document_name VARCHAR(200) NOT NULL,
PRIMARY KEY (download_id)")
 or die(mysql_error());  

echo "Table Created!";
+2  A: 

Looks like you're not closing the paren you opened just after download_list.

Alex Martelli
It seems like the paren I opened just after download_list is closed here: "or die(mysql_error()); ". Is that right?
no you never actually closed that paren. infact a decent editor ought to highlight that for you
Sujoy
Where should the close paren go? I'm using Aptana as an editor and my original code is not triggering an error.
is this the correct spot to add the missing paren? "PRIMARY KEY (download_id))")" .... I'm referring to the second close paren
Yes Alex, your answer is correct and the "spot" I previously mentioned was the fix. This was a huge help.