也许它只是我是一个菜鸟,但对于我的生活,我无法阻止下面的代码恢复到以下错误。
Mysql错误:您的SQL语法中有错误;检查手册 对应于您的MySQL服务器版本,以获得正确的语法 在第4行'WHERE id = 113'附近使用
ID(在这种情况下为ID 113)确实与数据库匹配,但仍然没有乐趣。
非常感谢您的帮助,我真的很感激。
<?php
ob_start();
error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
function isLoggedIn()
{
if(isset($_SESSION['valid']) && $_SESSION['valid'])
return true;
return false;
}
session_start();
//if the user has not logged in
if(!isLoggedIn())
{
header('Location: ../main');
die();
}
//! Checks that a restaurant is logged on
if ($_SESSION['user_type'] !== 'restaurant')
{
echo('You need to be a restaurant user to do that!, If you are seeing this message in error, please contact the system administrator.');
die();
}
//! Checks for direct access to page
if (empty($_GET)) {
header('location:../main/menu-manager.php?result=nothingentered');
die();
}
//! Get info from POST
$ID = $_GET['optionid'];
$rest_ID = $_SESSION['rest_id'];
//! security real escape
$ID = mysql_real_escape_string($ID);
//! Connect to the database
require_once('../Connections/PropSuite.php');
mysql_select_db($database_Takeaway, $Takeaway);
//! Write the information to the database
$query = "UPDATE menu_cats
SET rest_id = 'd.$rest_ID',
WHERE id = $ID ";
mysql_query($query);
if( mysql_errno() != 0){
// mysql error
// note: message like this should never appear to user, should be only stored in log
echo "Mysql error: " . htmlspecialchars( mysql_error());
die();
}
else {
header('Location: ../main/menu-manager.php?result=success');
}
?>
答案 0 :(得分:5)
在Where子句之前,您的SQL语句中不需要逗号。
答案 1 :(得分:4)
您必须在where
$query = "UPDATE menu_cats
SET rest_id = 'd.$rest_ID'
WHERE id = $ID ";
答案 2 :(得分:4)
您的查询中有一个迷路,
。查询应该是这样的:
$query = "UPDATE menu_cats
SET rest_id = 'd.$rest_ID'
WHERE id = $ID ";