Opencart Checkout我的sql错误

时间:2012-06-03 15:24:15

标签: php mysql database paypal opencart

每当我们使用bussoc paypal快速结账选项时...我输入paypal帐户登录和付款后继续按钮出现一个msg与mysql服务器错误,这里msg出现了一个客户回来后,​​在paypal上付款

  

注意:错误,您的SQL语法中有错误,请检查与您的MYSQL服务器版本对应的手册,以便使用接近订单的正确语法SET customer_id ='27'WHERE order_id ='279'在第1行

     

错误号码1064

     

更新订单SET customer_id ='27'WHERE order_id ='279'在home / public_html / site / system / database / mysql.php第49行   这是查询。那么需要改变的地方呢?

<?php
final class MySQL {
private $connection;

public function __construct($hostname, $username, $password, $database) {
    if (!$this->connection = mysql_connect($hostname, $username, $password)) {
        exit('Error: Could not make a database connection using ' . $username . '@' . $hostname);
    }

    if (!mysql_select_db($database, $this->connection)) {
        exit('Error: Could not connect to database ' . $database);
    }

    mysql_query("SET NAMES 'utf8'", $this->connection);
    mysql_query("SET CHARACTER SET utf8", $this->connection);
    mysql_query("SET CHARACTER_SET_CONNECTION=utf8", $this->connection);
    mysql_query("SET SQL_MODE = ''", $this->connection);
}

public function query($sql) {
    $resource = mysql_query($sql, $this->connection);

    if ($resource) {
        if (is_resource($resource)) {
            $i = 0;

            $data = array();

            while ($result = mysql_fetch_assoc($resource)) {
                $data[$i] = $result;

                $i++;
            }

            mysql_free_result($resource);

            $query = new stdClass();
            $query->row = isset($data[0]) ? $data[0] : array();
            $query->rows = $data;
            $query->num_rows = $i;

            unset($data);

            return $query;  
        } else {
            return true;
        }
    } else {
        trigger_error('Error: ' . mysql_error($this->connection) . '<br />Error No: ' . mysql_errno($this->connection) . '<br />' . $sql);
        exit();
    }
}

public function escape($value) {
    return mysql_real_escape_string($value, $this->connection);
}

public function countAffected() {
    return mysql_affected_rows($this->connection);
}

public function getLastId() {
    return mysql_insert_id($this->connection);
}   

public function __destruct() {
    mysql_close($this->connection);
}
}
?>

2 个答案:

答案 0 :(得分:1)

您的表名为order。这是MySQL中的保留关键字。你需要用反引号来逃避它

update `order` 
SET customer_id='27' 
WHERE order_id='279'

答案 1 :(得分:1)

update `oc_order` 
SET customer_id='27' 
WHERE order_id='279'

您已为表名添加了前缀。当您安装了opencart时,已添加此前缀。

默认情况下,它是'oc_',如果你改变它,那么用它替换它