1

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?

1 Answer 1

3
$this->prefixed('settings') . ' WHERE name = ?');
                               ^ add space here
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.