Your $db variable ain't global. XP
Before that line, insert:
---leave out the "query_first" bit, that's just a method of your object.
Not sure that this is your only error, but that's where you're having the trouble at the moment.
--------------- Added [DATE]1262191036[/DATE] at [TIME]1262191036[/TIME] ---------------
Basically, inside any function, if $db is not specifically declared as a global variable, it will only look at the variables LOCAL to the function.