MySQLi OOP Class Insert Function Not Working
<p>I am currently practicing OOP, creating a MySQLi class that will have atleast the basic MySQLi functions (insert, select, update, etc). This is what I have got so far:</p>

<pre><code>if(!class_exists('dbc')) {
class dbc {
    public function __construct($host = host, $username = username, $password = password, $database = database) {
        // Make the constants class variables
        $this-&gt;host = host;
        $this-&gt;username = username;
        $this-&gt;password = password;
        $this-&gt;database = database;

        $this-&gt;connection = new mysqli($this-&gt;host, $this-&gt;username, $this-&gt;password, $this-&gt;database);

        if($this-&gt;connection-&gt;connect_errno) {
            die('Database connection error!');
            return false;
        }
    }

    public function __deconstruct() {
        if($this-&gt;connection) {
            $this-&gt;connection-&gt;close();
        }
    }

    public function insert($table, $variables = array()) {
        if(empty($table) || empty($variables)) {
            return false;
        }

        $sql = "INSERT INTO $table ";

        $fields = array();
        $values = array();
        foreach($variables as $field =&gt; $value) {
            $fields[] = "'" . $field . "'";
            $values[] = "'" . $value . "'";
        }

        $fields = '(' . implode(', ', $fields) . ')';
        $values = '(' . implode(', ', $values) . ')';

        $sql .= $fields . ' VALUES ' . $values;

        $query = $this-&gt;connection-&gt;query($sql);

        if(!$query) {
            echo mysqli_error($this-&gt;connection);
        }

        echo $sql;
    }
}
}
</code></pre>

<p>As you can see, I create the connection via the details from the config file, I then send a query through the established connection. But for some reason when I attempt to create a MySQLi insert query, I just get the same error over, and over again:</p>

<blockquote>
  <p>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 ''name', 'option') VALUES ('Sub Title', 'This is a test website')' at line 1</p>
</blockquote>

<p>I even echoed out the sql query, which appeared to be the correct format:</p>

<blockquote>
  <p>INSERT INTO options ('name', 'option') VALUES ('Sub Title', 'This is a test website')</p>
</blockquote>

<p>I have spent hours of Googling, trial and error, etc, trying to fix this, and have had no luck, and as it's 12:30am, I'm tired and may be missing something critical, so if anyone knows what is causing this problem, it'll be greatly appreciated for a solution, etc.</p>

<p>Thanks,
Kieron</p>