我試圖插入一條記錄到使用PDO的MySQL,我的sql語句可以在下面的代碼中看到。SQLSTATE [42S22]:未找到列:1054未知列
<?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未知列「約翰」在 「字段列表」
這無疑是一個簡單的解決這個問題,但我似乎無法看到它,任何人都可以指出我正確的方向嗎?
接受大聲的時候,感謝有趣的鏈接。 – 2012-04-12 18:08:17