Zaloguj | Zarejestruj | FAQ
Anonymous

Problem creating tables in mysql database

+ Odpowiedz

Posty: 3 Strona 1 z 1


Problem creating tables in mysql database

przez bmedia » Cz kwi 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
Kod: Zaznacz cały
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();
Avatar użytkownika

bmedia

  • Posty: 10
  • Dołączył(a): So mar 29, 2014 7:56 am

Re: Problem creating tables in mysql database

przez XainPro » Pt kwi 25, 2014 12:39 pm

I Think there is error in your SQL Statement try this

Kod: Zaznacz cały
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();
Avatar użytkownika

XainPro

  • Posty: 3933
  • Dołączył(a): Pt lut 17, 2012 8:10 pm

Re: Problem creating tables in mysql database

przez bmedia » So kwi 26, 2014 11:15 am

Thanks,
I will use that and see
Avatar użytkownika

bmedia

  • Posty: 10
  • Dołączył(a): So mar 29, 2014 7:56 am


+ Odpowiedz

Strona 1 z 1

cron