Alright, for some odd reason, the below syntax is incorrect. I have successfully connected to the database on previous lines, now i'm trying to create a table.
The error I get is:

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 'PRIMARY_KEY, username VARCHAR(255) NOT NULL UNIQUE_KEY, email VARCHAR(255) IND' at line 2

The stranger part is that the query below starts on line 22 and line 2 is blank.

mysql_query("CREATE TABLE users(
	userid INT(11) NOT NULL AUTO_INCREMENT PRIMARY_KEY,
	username VARCHAR(255) NOT NULL UNIQUE_KEY,
	email VARCHAR(255) INDEX,
	password VARCHAR(255),
	role TINYINT(2) UNSIGNED,
	status TINYINT(2) UNSIGNED,
	lastip INT(10) UNSIGNED,
	first_name VARCHAR(255),
	last_name VARCHAR(255)
)") or die('<span style="color:red">Could not create table users in ' . $dbname . ': ' . mysql_error() . '</span><br>');
echo "<span style=\"color:green\">Table has been successfully created!</span><br>";

I have tried just about every kind of troubleshooting and I can't seem to get the error to go away. If you see the error, please let me know.

To answer my own question above, here is the solution. I placed PRIMARY_KEY instead of PRIMARY KEY.

mysql_query("CREATE TABLE users(
	userid INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
	username VARCHAR(255) NOT NULL UNIQUE KEY,
	email VARCHAR(255) INDEX,
	password VARCHAR(255),
	role TINYINT(2) UNSIGNED,
	status TINYINT(2) UNSIGNED,
	lastip INT(10) UNSIGNED,
	first_name VARCHAR(255),
	last_name VARCHAR(255)
)") or die('<span style="color:red">Could not create table users in ' . $dbname . ': ' . mysql_error() . '</span><br>');
echo "<span style=\"color:green\">Table has been successfully created!</span><br>";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.