我試圖更新我的MySQL表,但它拋出一個錯誤來更新表是這樣的:是有可能使用PDO準備statment
'SQLSTATE[HY093]: Invalid parameter number: parameter was not define'
這裏是我的代碼
$sql = "
UPDATE registration
SET fname, city, zip_code, state, tele_no, PayPal_email, mobile_no,address
VALUES :name, :city, :zip_code, :state, :tele_no, :PayPal_email, :mobile_no, :address
WHERE id = $id
";
$result = $stud->update($sql, array(":fname"=>$fn, ":city"=>$ct, ":zip_code"=>$zp, ":state"=>$st, ":tele_no"=>$off, ":PayPal_email"=>$pel, ":mobile_no"=>$mn, ":address"=>$ad));
[命名佔位符是最知名的PDO的優勢之一(https://phpdelusions.net/pdo/mysqli_comparison#named) –
謝謝@YourCommonSense它是非常有用的鏈接 –