....only trouble is some code he did is going wrong and he never made any comments on his work so i cant find out why the error is occuring
Ha, I always laugh at comments like that.
First up, the code reads fine. Any decent programer can read this and locate errors. johanafm is right. $this->db hasn't been set to a valid object, but its not this code that is at fault. The error provided by PHP is sufficient to indicate the issue.
Complaining about a coder not "commenting" work is like blaming your electrian, mechanic, or builder for not commenting his work.
The fact is, most IT companies dont get "commented code" for one very simple reason. They dont pay for "commented code".
Commenting code (or documentation) is a task like anything else and takes time.
If you dont pay for it, you dont get it.
Its as simple as that. And its not the job of a skilled worker to educate an employer in the event an employer chooses that they dont want to pay for any more work, and wishes todo the work themselves.
Like, really. Its like asking your doctor to explain how to fix a broken leg, then trying to do the work yourself.
If you want skilled work, you have to pay for it.
Or, you can go buy some stupid "Learn PHP in 30 days" or, "Dummies Guide to PHP" and think you can do the work of someone whos been coding for 20+ years.
Im currently reading "Home Surgery for Dummies". Cool