嘿,我正在尝试使用此隐藏表单传递 xml 值:
<form method='post' action='addholiday.php' id='addHoliday'>
<input type='hidden' name='title' id='title' value= '.$holiday->title'>
<input type='hidden' name='link' id='link' value= '.$holiday->link'>
<input type='hidden' name='date' id='date' value= '.$holiday->pudDate'>
<input type='hidden' name='description' id='description' value= '.$holiday->description'>
<input type='submit' name='submit' value='Add Holiday'>";
并使用 PDO 进程将值插入 mysql 数据库:
$db = getConnection();
//get holiday infor from hidden form
$user = $_SESSION['user'];
$title = $_POST['title'];
$link = $_POST['link'];
$date = $_POST['date'];
$description = $_POST['description'];
//insert the values in to favorties table
$sql = "INSERT INTO saved_holidays (subscriberID, link, pubDate, title, description,dateSaved)
VALUES (:subscriberID, :link, :pubDate, :title, :description, now())";
$stmt = $db->prepare($sql);
$stmt ->bindParam(':subscriberID', $user);
$stmt ->bindParam(':link', $link);
$stmt ->bindParam(':pubDate',$date);
$stmt ->bindParam(':title', $title);
$stmt ->bindParam(':description', $description);
$stmt->execute(array($user, $link, $date, $title, $description ));
但是,当我尝试使用表单时,我不断收到此错误消息
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]:
Invalid parameter number: parameter was not defined' in var/www/vhosts/numyspace.co.uk/web_users/home/~unn_w11023553/public_html/holiday/addholiday .php:39 Stack trace: #0
/var/www/vhosts/numyspace.co.uk/web_users/home/~unn_w11023553/public_html/holiday/addholiday.php(39):PDOStatement->execute(Array) #1 {main} thrown in /var/www/vhosts/numyspace.co
.uk/web_users/home/~unn_w11023553/public_html/holiday/addholiday.php on line 39
我对使用 PDO 比较陌生,所以任何帮助将不胜感激谢谢