嗨,我在 mysql 中有一个表,有六个字段
ID, mobileNumber, firstName, lastName, email, password , rollID
ID 是自动增量的,我想使用 php 插入它
php代码
public function run($firstName, $lastName, $mobileNumber, $email, $password, $rePassword) {
if (!$this->db->isExistedMobile($mobileNumber)) {
try {
$query = "INSERT INTO user (firstName, lastName, mobileNumber, email, password, rollID)
VALUES (:firstName, :lastName, :mobileNumber, :email, :password, 'rollID')";
$sth = $this->db->prepare($query);
$sth->execute(array(
':firstName' => $firstName,
':lastName' => $lastName,
':mobileNumber' => $mobileNumber,
':email' => $email,
':password' => $password,
':rollID' => "roma"
));
header("location: " . URL . "index");
} catch (PDOException $e) {
die($e->getMessage());
exit;
}
} else {
include 'controlers/Error.php';
$error = new Error();
$error->index("you enterd a used mobile number");
}
}
我有这个例外
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
函数 isExistedMobile 总是返回 false 所以不用担心,我不知道哪里错了,是语法吗?或者在rollID cos中我让它成为静态的?谢谢你的帮忙 :)