-1

多分それは私が初心者であるだけですが、私の人生の間、私は次のエラーに戻る以下のコードを止めることはできません。

Mysqlエラー:SQL構文にエラーがあります。4行目の「WHEREid=113」の近くで使用する正しい構文については、MySQLサーバーのバージョンに対応するマニュアルを確認してください。

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');

}


?>
4

3 に答える 3

5

SQLステートメントのWhere句の前にコンマは必要ありません。

于 2013-02-04T19:40:32.487 に答える
4

前にカンマを削除する必要がありますwhere

$query = "UPDATE menu_cats
            SET rest_id = 'd.$rest_ID'
            WHERE id = $ID ";
于 2013-02-04T19:41:07.470 に答える
4

クエリに迷い,があります。クエリは次のようになります。

$query = "UPDATE menu_cats
        SET rest_id = 'd.$rest_ID'
        WHERE id = $ID ";
于 2013-02-04T19:41:09.003 に答える