所以我在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')));
}
你看到了吗?
答案 0 :(得分:3)
$this->prefixed('settings') . ' WHERE name = ?');
^ add space here