助けてください :)。私はこのエラーを取得しています:
Warning: mysqli::prepare() [mysqli.prepare]: (42000/1064): 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 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id))' at line 1 in ***/classes/db.mysql.class.php on line 69
Warning: mysqli::prepare() [mysqli.prepare]: (42000/1064): 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 '?)' at line 1 in ***/classes/db.mysql.class.php on line 75
このphpコード呼び出しで:
public function createTable($tableName) {
$this->connect();
if ($stmt = $this->dbSocket->prepare("CREATE TABLE ?(id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id))")) {
$stmt->bind_param("s", $tableName);
$stmt->execute();
$stmt->close();
}
if ($stmt = $this->dbSocket->prepare("INSERT INTO sys_userTables(userTableName) VALUES (u_?)")) {
$stmt->bind_param("s", $tableName);
$stmt->execute();
$stmt->close();
}
$this->disonnect();
}
$tableName は文字列であり、正しく渡されます。
connect() メソッドは次のとおりです。
private function connect() {
$this->dbSocket = new mysqli($this->dbHost, $this->dbUser, $this->dbPassword, $this->dbDatabase);
if (mysqli_connect_errno()) {
printf("Brak połączenia z serwerem MySQL. Kod błędu: %s\n", mysqli_connect_error());
exit();
}
}
ティア。