php
  • mysql
  • sql
  • mysqli
  • mysql-error-1064
  • 2015-01-02 187 views 0 likes 
    0

    嗨,大家好,我有一個在PHP更新記錄查詢問題。Mysql查詢更新從PHP

    <?php 
    include('../webcgo/script/cox.php'); 
    $query = $cox->query("SELECT cf_id FROM offerte;"); 
    while ($idx = mysqli_fetch_array($query)) { 
        $check = '<button class="uk-button" onclick="location.href=\'http://localhost/chartscript/remRegola.php?dis=2&id=' . $idx['cf_id'] . '\'">OK</button>'; 
        $query_check = 'UPDATE offerte SET check=\'' . $check . '\' WHERE cf_id=' . $idx['cf_id'].';'; 
        if ($queryx = $cox->query($query_check) === TRUE) { 
         echo "Record updated successfully"; 
        } else { 
         echo "Error updating record: " . $cox->error; 
    
        } 
    } 
    mysqli_close($cox);?> 
    

    結果: 錯誤更新記錄:您的SQL語法錯誤;檢查對應於您的MySQL服務器版本的手冊,以便在'check ='處使用正確的語法'

    +0

    如果你回聲'$ query_check'你? –

    +1

    'check'是[保留字](http://dev.mysql.com/doc/refman/5.6/en/reserved-words.html) –

    回答

    2

    checkMySQL reserved keyword。如果你打算在查詢中使用它,你必須包裹它反引號:

    $query_check = 'UPDATE agoragroup_chronoforms_data_inserimento_offerte_prod SET `check`=\'' . $check . '\' WHERE cf_id=' . $idx['cf_id'].';'; 
    
    +0

    你是對的 – fortune

    相關問題