能naybody告訴我這是什麼意思不能在SQLite表中插入字符串,但可以數字
INSERT INTO users(first_name,last_name,email,username,password,privilege) VALUES('s',1,1,1,1,1);
但是當我嘗試
INSERT INTO users(first_name,last_name,email,username,password,privilege) VALUES(1,1,1,1,1,1);
它的工作原理。我不能插入字符串?哪裏不對 ? 我的SQLite表看起來像
CREATE TABLE users (
id integer PRIMARY KEY AUTOINCREMENT NOT NULL,
first_name varchar(50),
last_name varchar(50),
email varchar(50),
username varchar(50),
password varchar(50),
privilege varchar(50)
);
和我的PHP函數看起來像
public function insert_user($first_name, $last_name, $email, $username, $password, $privilege) {
try {
$db = new SQLite3($this->db_path);
$db->query("INSERT INTO users(first_name,last_name,email,username,password,privilege) VALUES($first_name,$last_name,$email,$username,$password,$privilege);");
$last_id = $db->lastInsertRowID();
$db->close();
return $last_id;
} catch (Exception $e) {
echo 'Exception caught: ', $e->getMessage(), "\n";
}
}