In order to manipulate or read data, SQL has statements. Statements are anything and everything that will manipulate or read data from a database, regardless of the type of SQL database. Every statement, or query, has to be executed individually. The way SQL does this is to have each statement end with a semicolon. What you're trying to do is execute two separate statements as a singular one. Place a semicolon at the end of each CREATE TABLE statement's instance of ) and you should be good to go. Here's a trimmed example:
Also, the last row in your second create statement ends in a comma (EMAIL Varchar(60), ) - which, as the last line, it shouldn't have.
Odd that you create the tables if there is *anything* in the post array - I'd certainly set some sort of semaphore so that you know that the request came from the correct page, and perhaps also consider what to do if the tables already exist - do you drop them, or just die with an error message, or be more sophisticated about it?
Regards,
Pete.
I'm trying to create a table through MySQL but it's not working. Any tips?
include('../config.php');
if($_POST){
mysql_query("
CREATE TABLE users (
ID INT(6) AUTO_INCREMENT PRIMARY KEY,
Username VARCHAR(30),
Password VARCHAR(30),
FirstName VARCHAR(30),
LastName VARCHAR(30),
Email VARCHAR(30)
)
CREATE TABLE admin (
Username VARCHAR(30),
Password VARCHAR(30),
Email VARCHAR(60),
)
");
}
?>