登录 | 注册 | FAQ
Anonymous

Problem creating tables in mysql database

+ 发表回复

3 篇帖子 分页: 1 / 1


Problem creating tables in mysql database

bmedia » 周四 4月 24, 2014 8:34 am

I was able to use the command to create the database.
But creating tables was the problem.
I think it has to do with the version.

This is the reponse:
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) )' at line 7,

Below is the code
代码: 全选
mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("MyDatabase")or die(mysql_error());
mysql_query("CREATE TABLE MyTable(
id INT AUTO_INCREMENT,
FirstName CHAR,
LastName CHAR,
Phone INT,
BirthDate DATE
PRIMARY KEY(id)
)")  or die(mysql_error());
mysql_close();
头像

bmedia

  • 帖子: 10
  • 注册: 周六 3月 29, 2014 7:56 am

Re: Problem creating tables in mysql database

XainPro » 周五 4月 25, 2014 12:39 pm

I Think there is error in your SQL Statement try this

代码: 全选
mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("MyDatabase")or die(mysql_error());
mysql_query("CREATE TABLE `mytable` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `FirstName` char(10) NOT NULL,
  `LastName` char(10) NOT NULL,
  `Phone` int(11) NOT NULL,
  `BirthDate` date NOT NULL,
  PRIMARY KEY (`id`)
)")  or die(mysql_error());
mysql_close();
头像

XainPro

  • 帖子: 3933
  • 注册: 周五 2月 17, 2012 8:10 pm

Re: Problem creating tables in mysql database

bmedia » 周六 4月 26, 2014 11:15 am

Thanks,
I will use that and see
头像

bmedia

  • 帖子: 10
  • 注册: 周六 3月 29, 2014 7:56 am


+ 发表回复

分页: 1 / 1