I am writing some software right now. Reader’s digest version: users select a package, and enter their name, email, and desired subdomain. A subdomain is then checked to see if someone already registered it and if it is only alphanumeric. I had all of this working using MySQL, but I have decided to make the move to PDO.
The exact wording of the error:
The stack trace is all over the place, and I can barely figure out when to begin troubleshooting this. I have checked the other answers here, and they all seem too localized, so here’s the code that produces it, then all of the methods that contain errors. Here we go…
migrate_1401_04_22_12_03_00_users.php
public function up()
{
$db = Application::$app->database;
$sql = "CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name(255) NOT NULL,
first_name(255) NOT NULL,
last_name(255) NOT NULL,
email(255) NOT NULL,
password(255) NOT NULL,
status TINYINT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=INNODB;";
$db->pdo->exec($sql);
}
>Solution :
String field types need to be specified with the keyword VARCHAR
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
status TINYINT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=INNODB;