doz59484 2011-11-24 15:30
浏览 14
已采纳

PHP不会创建表? [重复]

This question already has an answer here:

currently I'm making a forum software, and I'm writing the install script, that sets up the database and tables within it. It makes the database and tables fine. It's supposed to make 4 tables: forums, posts, topics, and user_info.

It successfully makes the databse, forums, posts, and topics, but it doesn't create the user_info table, and I can't figure out why.

Here's my code:

$createdb = "CREATE DATABASE forumstest";
$run_createdb = mysql_query("$createdb");

//Create tables
mysql_select_db("forumstest");

$createforums = "CREATE TABLE forums (id int NOT NULL, description text, PRIMARY KEY (id))";
mysql_query("$createforums");

$createposts = "CREATE TABLE posts (id int NOT NULL, created_by varchar(200), date_created date, the_post text, topic_id text, PRIMARY KEY (id))";
mysql_query("$createposts");

$createtopics = "CREATE TABLE topics (id int NOT NULL, title varchar(200), created_by varchar(200), date_created date, forum_id text, PRIMARY KEY (id))";
mysql_query("$createtopics");

$createtopics = "CREATE TABLE user_info (id int NOT NULL, username varchar(25), password varchar(100), name varchar(65), email varchar(65), date date, group text, PRIMARY KEY (id))";
mysql_query("$createtopics");

$dbcreated = 1;
echo "Database created sucessfully!";
</div>
  • 写回答

4条回答 默认 最新

  • doushao5047 2011-11-24 15:31
    关注

    date is, just like group, a reserved keyword, which you would have seen if you did some error checking.

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

报告相同问题?

悬赏问题

  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示