dongxu1668 2013-06-19 17:48
浏览 51
已采纳

使用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.

  • 写回答

2条回答 默认 最新

  • duanliang8464 2013-06-19 17:52
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏