user1819037
user1819037

Reputation: 9

SQL Syntax error. Suddenly broke?

When trying to create this table, it doesn't want to work properly though it worked minutes before? Assume that $username is equal to "Test" for brevity.

The error I'm receiving 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 '( id(10) INT AUTO_INCREMENT, PRIMARY KEY(id), message varchar(250), ' at line 2

This is the code I'm currently using:

$sql = "CREATE TABLE {$username}
(
id(10) INT AUTO_INCREMENT,
PRIMARY KEY(id),
message varchar(250),
sender varchar(100)
)";

Upvotes: 0

Views: 61

Answers (1)

earl3s
earl3s

Reputation: 2373

You have a SQL syntax error.

Instead of id(10) INT AUTO_INCREMENT It should be id INT(10) AUTO_INCREMENT

Upvotes: 2

Related Questions