I'm sure this must be a simple answer but I'm just not seeing it. I'm experimenting with moving all my database code into a class for the sake of simplifying all the rest of my code.

I have run into this error and I can't see why

Fatal error: Using $this when not in object context in /var/www/php/dbclass.php on line 18 (I've marked line 18 with an arrow)

Here is my class

```
<?php

class kdb {

    var $dbhost = "localhost";
    var $dbname = "name";
    var $dbuser = "root";
    var $dbpass = "pass";

    var $error;

//    function __construct($persons_name) {
//        $this->name = $persons_name;
//    }
    //function to insert safely

    public static function exe($qry_string, $var_array) {
        $host = $this->dbhost;  <------------------ LINE 18
        $name = $this->dbname;
        $user = $this->dbuser;
        $pass = $this->dbpass;
        $retries = 30;
        while ($retries > 0) {
            try {
                $pdo_conn = new PDO("mysql:host={$host};dbname={$name}", $user, $pass);
                $retries = 0;
                //echo 'run query';
            } catch (PDOException $e) {
                $retries--;
                sleep(1); // Wait 1s between retries.
                log::enter_log("Error connecting: {$retries} retries left");
            }
        }
        $q = $pdo_conn->prepare($qry_string);
        $q->execute($var_array);
        $return_arr = $q->fetchAll();
        $this->error = $q->errorInfo();
        //dbconn::logquery($qry_string, $var_array, $q->rowCount(), $error[2]);
        return $return_arr;
    }

}

?>

```

and the code on the page

```
    $db = new kdb();   
    $db_list = $db->exe('select * from table where id = ?', array(42));
    var_dump($db_list);

```

Please be aware it is only half finished, I am aware that at the moment it is more complicated than it needs to be.