使用php创建mysql表时出错

$createtable=mysql_query("CREATE TABLE IF NOT EXISTS users(username VARCHAR(20),password VARCHAR(20),read TINYINT(1),write TINYINT(1),search TINYINT(1))");

I get the following error when trying to create the table using the above query: Error creating user table: 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 'read TINYINT(1),write TINYINT(1),search TINYINT(1))' at line 1

how do i successfully create the table?thanks in advance.

try this

 $createtable=mysql_query("CREATE TABLE IF NOT EXISTS users(username VARCHAR(20),password VARCHAR(20),`read` TINYINT(1),`write` TINYINT(1),search TINYINT(1))");

you have read and write are mysql reserved keywords , so you should around them by backticks

Try:

$createtable=mysql_query("CREATE TABLE IF NOT EXISTS users(`username` VARCHAR(20),`password` VARCHAR(20),`read` TINYINT(1),`write` TINYINT(1),`search` TINYINT(1))");