PHP OOP: Accessing Variables
<p>I have the following "Student" Class:</p>

<pre><code>class Student {
    public $user_id;
    public $name;

    public function __construct($user_id) {
        $info = $this-&gt;studentInfo($user_id);
        $this-&gt;name = $info['name'];
        $this-&gt;is_instructor = $info['is_instructor'];
        $this-&gt;user_id = $info['id'];
    }

    public static function studentInfo($id) {
        global $db;

        $u = mysql_fetch_array(mysql_query("SELECT * FROM $db[students] WHERE id='$id'"));
        if($u) {
             return $u;
        }
    }        

    public static function getCoursesByInstructor() {
        global $db;

        return mysql_query("SELECT courses.*, course_types.name FROM $db[courses] as courses 
                            JOIN $db[course_types] as course_types ON courses.course_type_id=course_types.id
                            WHERE instructor_id='$this-&gt;user_id'");
    }
}
</code></pre>

<p>I'm trying to do:</p>

<pre><code>$u = new Student(1);
$courses = $u-&gt;getCoursesByInstructor();
</code></pre>

<p>But am getting the following error:</p>

<p>Fatal error: Using $this when not in object context in /Applications/MAMP/htdocs/flight1/phpincludes/classes/students.class.php on line 54</p>
