2

Hello guys i have worked on mysqli but not pdo sqlite i don't know what syntax is to create tables here if not exists this is my code please tell me why am i getting error on last line.

$Database = new PDO('sqlite:'.$DB_Path);
$Database->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$Database->exec(
        "CREATE TABLE IF NOT EXISTS Requests
          (
            ID INT( 11 ) AUTO_INCREMENT PRIMARY KEY, 
            Sender VARCHAR( 225 ), 
            Recipient VARCHAR( 225 )
          )
      ");

1 Answers1

2

It is most likely because you have specified the size for INT: ID INT( 11 ). Why do you need it? Try this syntax (add NOT NULL for Primary key):

CREATE TABLE IF NOT EXISTS Requests
      (
        ID INT NOT NULL PRIMARY KEY AUTOINCREMENT, 
        Sender VARCHAR( 225 ), 
        Recipient VARCHAR( 225 )
      )
cha
  • 1,055
  • 5
  • 7