<?php
include('connect.php');
$date = $_POST['date'];
$student_ID = $_POST['student_ID'];
$full_name = $_POST['full_name'];
$year_section = $_POST['year_section'];
$payment_description = $_POST['payment_description'];
$amount = $_POST['amount'];
$received_by = $_POST['received_by'];
// query
$sql = "INSERT INTO transaction (date,student_ID,full_name,year_section,payment_description,amount,received_by) VALUES (:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft)";
$q = $db->prepare($sql);
$q>execute(array(':sas'=>$date,':asas'=>$student_ID,':asafs'=>$full_name,':offff'=>$year_section,':statttt'=>$payment_description,':dot'=>$amount,':rd'=>$received_by));
header("location: index.php");
?>
我收到以下錯誤:未捕獲的異常 'PDOException' 有消息「SQLSTATE [HY093]:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in C:\xampp\htdocs\recordmanagement\main\reg.php:15 Stack trace: #0 C:\xampp\htdocs\recordmanagement\main\reg.php(15): PDOStatement->execute(Array) #1 {main} thrown in C:\xampp\htdocs\recordmanagement\main\reg.php on line 15
在代碼中,我還不能確定這些值的含義:
(:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft);
我從源代碼下載它,所以它不是由我寫的。
@Alex K.爲什麼這個問題變成了社區wiki? – jpw
這個問題變成了一個社區wiki,因爲審稿人和提出修改的人都沒有做他們應該做的事。在帖子變得足夠好之前,它花了12次修訂,這應該只用1次完成。一篇帖子在10次修訂後成爲社區wiki。 –
@JeroenVannevel我明白了。我不知道經過一定的修改後,帖子變成了維基。感謝澄清。 – jpw