我正在尝试使用 PDO 向 MySQL 插入一条记录,我的 sql 语句可以在以下代码中看到。
<?php
try{
//include file myfunctions.php allows us to calls functions from it
include ("myfunctions.php");
//Assign function getConnection() from myfunctions.php to variable $db
$db = getConnection();
foreach($_POST['chk'] as $check_value)
{
$check = $check_value;
$fav = "channel/item [title = \"$check\"]";
$holidayDoc = simplexml_load_file('holidays.xml');
$favourites = $holidayDoc->xpath($fav);
foreach($favourites as $currentFav)
{
echo "{$currentFav->link}". "<br \>";
echo "{$currentFav->title}". "<br \>";
echo "{$currentFav->description}". "<br \>";
echo "{$currentFav->pubDate} ". "<br \>";
$sql = "INSERT INTO `saved_holidays` (`subscriberID`, `link`, `pubDate`, `title`, `description`)
VALUES (`John`, `$currentFav->link`, `$currentFav->pubDate`, `$currentFav->title`, `$currentFav->description`)";
$db->exec($sql);
$db = null;
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
?>
执行此代码时,我遇到以下错误消息;
SQLSTATE [42S22]:找不到列:1054 '字段列表'中的未知列 'John'
这无疑是解决这个问题的一个简单方法,但我似乎看不到它,谁能指出我正确的方向?