Login   Register  
PHP Classes
elePHPant
Icontem

Can't run create table function

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      PDO Multi Connection Class  >  All threads  >  Can't run create table function  >  (Un) Subscribe thread alerts  
Subject:Can't run create table function
Summary:Can't run create table function
Messages:3
Author:Bertho Joris
Date:2013-07-14 07:09:11
Update:2013-07-15 14:29:28
 

  1. Can't run create table function   Reply  
Picture of Bertho Joris
Bertho Joris
2013-07-14 07:09:11
I am trying to create a table in my database, but when running the function no action happens. I followed your example script

  2. Re: Can't run create table function   Reply  
Picture of Evert Ulises German Soto
Evert Ulises German Soto
2013-07-14 15:00:44 - In reply to message 1 from Bertho Joris
Hi Bertho Joris,

When you execute $db->query($query_create_table);
You must call $db->getError();
Some like this:

$db->query($query_create_table);
echo $db->getError();

Doing this you can see the error in your query or restriction on database.
If you have more problems contact me: salsadelmonte@hotmail.com

  3. Re: Can't run create table function   Reply  
Picture of Evert Ulises German Soto
Evert Ulises German Soto
2013-07-15 14:29:28 - In reply to message 1 from Bertho Joris
Bertho Joris:
"Error: SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key"

...

Hi good day Bertho, you have an error in your ID, you must define the primary key like this:

CREATE TABLE TB_USERS_2 (
ID INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
NAME VARCHAR(100) NOT NULL,
ADDRESS VARCHAR(100) NOT NULL,
COMPANY VARCHAR(100) NOT NULL
);

Best Regards!