以下是我的代码,但在 where 子句中出现错误
<?php
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();
$response = array();
$dom = new DOMDocument();
$dom->loadHTMLFile("http://www.pizzahut.com.pk/deals.html");
//echo $dom->saveHTML();
$table = $dom->getElementsByTagName('td');
for($i = 30; $i < 35; $i++ ){
$deal = $table->item($i)->nodeValue;
echo $deal;
}
$id = 1813660169;
$result = mysql_query("INSERT INTO cafes(deal)
VALUES('$deal') WHERE `id` = " .$id) or die(mysql_error());
echo mysql_num_rows($result);
if ($result) {
// successfully inserted into database
$response["success"] = 1;
$response["message"] = "Place successfully created.";
// echoing JSON response
echo json_encode($response);
} else {
// failed to insert row
$response["success"] = 0;
$response["message"] = " ID already inserted";
// echoing JSON response
echo json_encode($response);
}
?>
错误是“您的 SQL 语法有错误;请查看与您的 MySQL 服务器版本相对应的手册,以id
在第 2 行的 'WHERE = 1813660169' 附近使用正确的语法”
需要帮助