sushibrain
sushibrain

Reputation: 2780

Fatal error: Uncaught exception 'Exception'

So I discovered the error in my prepared statement, this is the full error I'm getting:

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

Here is some code, but I don't see any errors. Also I've specificly checked that all database rows and tables exist.

class.functions.php (Line 79 to 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 (Line 9 to 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')));
}

Do you see anything?

Upvotes: 1

Views: 562

Answers (1)

FuzzyTree
FuzzyTree

Reputation: 32392

$this->prefixed('settings') . ' WHERE name = ?');
                               ^ add space here

Upvotes: 3

Related Questions