【问题标题】:Fatal error: Uncaught exception 'Exception'致命错误:未捕获的异常“异常”
【发布时间】:2014-08-26 13:44:38
【问题描述】:

所以我在prepared statement 中发现了错误,这是我得到的完整错误:

Fatal error: Uncaught exception 'Exception' with message 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= ?' at line 1' in C:\xampp\htdocs\w-classes\class.functions.php:82 Stack trace: #0 C:\xampp\htdocs\index.php(12): Functions->getSiteSetting('language') #1 {main} thrown in C:\xampp\htdocs\w-classes\class.functions.php on line 82

这是一些代码,但我没有看到任何错误。我还专门检查了所有数据库行和表是否存在。

class.functions.php(第 79 到 94 行)

public function getSiteSetting($setting) {
        $stmt = $this->mysqli->prepare('SELECT value FROM ' . $this->prefixed('settings') . 'WHERE name = ?');
        if(!$stmt) {
            throw new Exception($this->mysqli->error, 1);
        }
        $stmt->bind_param('s', $setting);
        $stmt->execute();
        $stmt->bind_result($result);
        $stmt->store_result();
        if($stmt->num_rows > 0) {
            while ($stmt->fetch()) {
                return $result;
            }
        }
        $stmt->close();
    }

index.php(第 9 到 15 行)

define('WCREATE_BASE', dirname(__FILE__));
include_once(WCREATE_BASE . '/w-core.php');

include_once(WCREATE_BASE . '/w-languages/lang.' . $functions->getSiteSetting('language') . '.php');
if(!existingTable($db->prefixed('settings'))) {
    displayErrors('no_table', array('table' =>  $db->prefixed('settings')));
}

你看到什么了吗?

【问题讨论】:

    标签: php


    【解决方案1】:
    $this->prefixed('settings') . ' WHERE name = ?');
                                   ^ add space here
    

    【讨论】:

      猜你喜欢
      • 2013-07-07
      • 1970-01-01
      • 2015-06-10
      • 2015-06-20
      • 2014-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多