$query2 = $dbs->prepare("INSERT INTO service_info(user_id)
SELECT id
FROM customer_info");
$query2 -> bindParam(':id',$_SESSION['id']);
if($query2->execute()){
return true;
}
else{
return false;
}
它不工作,爲什麼? 我的PDO查詢是否錯誤? 這是我的代碼在我的功能寄存器:
塊引用
public function register($firstname, $lastname, $email, $age, $contact, $gender, $password){
include '/include/db_config.php';
$query = $dbs->prepare("INSERT INTO customer_info(firstname,lastname,email,age,contact,gender,password)
VALUES(:firstname,:lastname,:email,:age,:contact,:gender,:password)");
$query -> bindParam(':firstname', $firstname);
$query -> bindParam(':lastname', $lastname);
$query -> bindParam(':email', $email);
$query -> bindParam(':age', $age);
$query -> bindParam(':contact',$contact);
$query -> bindParam(':gender',$gender);
$query -> bindParam(':password', $password);
if($query->execute()){
return true;
}
else{
return false;
}
$query2 = $dbs->prepare("INSERT INTO service_info(user_id)
SELECT id
FROM customer_info WHERE id = :user_id");
$query2 -> bindParam(':id',$_SESSION['user_id']);
if($query2->execute()){
return true;
}
else{
return false;
}
}
塊引用
所以這裏有什麼問題>。 < 請幫我即時乞討你們請
塊引用
您的查詢無效您試圖用SELECT實現什麼功能?您還將參數綁定到查詢,但查詢字符串沒有佔位符。 – JimL
什麼是綁定?您的查詢期望 –
以外的任何內容只是檢查錯誤,您會發現錯誤的位置。請參閱手冊 –