Thread:User talk:Jasper Deng/PHP/MySQL question

I'm working on a form application that I plan to use as a basis for the contact form extension I'm working on. (the login would be removed, as MediaWiki would provide the user accounts)

There's a problem that I get when I try to run the script for creating the database tables.

This is the page that has the script: ($dbprefix is just for this application, I'll change it to the one MediaWiki uses when I make the extension. I believe I may have entered that right)

 CREATE TABLE /*$dbprefix*/users (    -> user_id    int           AUTO_INCREMENT PRIMARY KEY,     -> username   varchar(30)   NOT NULL,     -> password   varchar(30)   NOT NULL     -> ) ";

mysql_query($create_user_table) or die(mysql_error);

// Create table for storing messages

$create_message_table = " mysql> CREATE TABLE /*$dbprefix*/messages (   -> message_id      int           AUTO_INCREMENT PRIMARY KEY,    -> sender_name     varchar(50)   NOT NULL,    -> sender_email    varchar(50)   NOT NULL,    -> sender_message  varchar(2000) NOT NULL    -> ) ";

mysql_query($create_message_table) or die(mysql_error);

// Create user account

$new_admin_create_account = " mysql> INSERT INTO /*$dbprefix*/users (username, password)           VALUES ('{mysql_real_escape_string($new_admin_username)}',                    '{mysql_real_escape_string($new_admin_password)}'); ";

mysql_query($new_admin_create_account) or die(mysql_error);

?>

Here's the error I get:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql> CREATE TABLE /**/users ( -> user_id int AUTO_INCREMENT ' at line 1