2014-07-05 112 views
1

所以我在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'))); 
} 

你看到什麼了嗎?

回答

3
$this->prefixed('settings') . ' WHERE name = ?'); 
          ^add space here 
相關問題