0

I have made a public function for getting, and showing a user's infraction info. When I put it on a page, it only shows what I have in the function, and not any of the other content on the page. It only shows the table headers, and none of the data. I get this error:

Fatal error: Call to a member function query() on a non-object in /Applications/AMPPS/www/classes/user.php on line 108

Also, I have other functions from the same class that work fine.

Here is the code for the function link (sorry about pastebining it, it was really long)

ryr11
  • 254
  • 4
  • 11

3 Answers3

0

Your $db object is null or can't be accessed. Your line 108 error does not match up with your code you have pasted and you don't have the code where you are creating your database object to see what may be wrong there.

Pixel Life
  • 16
  • 1
  • here is the entire class (all the other functions work fine): http://pastebin.com/K6kduJuR – ryr11 Mar 07 '14 at 03:19
0

The error message seems to indicate that your "$db" is not set to an object. Make sure its initialized properly.

Daniel
  • 4,481
  • 14
  • 34
0

The function never initializes the $db variable. If it's a class property, it should be $this->db or self::$db. If it's a global variable, you need to put global $db; at the beginning of the function.

Barmar
  • 741,623
  • 53
  • 500
  • 612