Todd88 Posted March 5, 2008 Share Posted March 5, 2008 Fatal error: Call to a member function on a non-object in /mysite/proof.php on line 14 I am using a mysql database to get the values for proof on my payment site. I guess I have something wrong in the code and it would be great if someone could just point it out to me. Here is the file: <? $includes[title]="Proof Of Payments"; ?> <table class="tableStyle" style="width:100%"> <tr> <th>Id</th> <th>Username</th> <th>Method</th> <th>Amount</th> <th>Date</th> </tr> <? $sql=$Db1->query("SELECT * FROM payment_history ORDER BY dsub DESC"); while($row=$Db1->fetch_array($sql)) { echo "<tr> <td>".$row['id']."</td> <td>".$row['username']."</td> <td>".$row['accounttype']."</td> <td>".$row['amount']."</td> <td>".date("M.D.Y",mktime(0,0,$row['dsub'],1,1,1970))."</td> </tr>"; } ?> </table> Any help is appreciated! Thanks! Link to comment https://forums.phpfreaks.com/topic/94447-fatal-error-call-to-a-member-function-on-a-non-objectgotta-hate-it/ Share on other sites More sharing options...
Isityou Posted March 5, 2008 Share Posted March 5, 2008 It seems your 'fetch_array()' method does not exist in your $Db1 object. Link to comment https://forums.phpfreaks.com/topic/94447-fatal-error-call-to-a-member-function-on-a-non-objectgotta-hate-it/#findComment-483689 Share on other sites More sharing options...
Todd88 Posted March 5, 2008 Author Share Posted March 5, 2008 I still can't seem to fix it Link to comment https://forums.phpfreaks.com/topic/94447-fatal-error-call-to-a-member-function-on-a-non-objectgotta-hate-it/#findComment-483692 Share on other sites More sharing options...
darkfreaks Posted March 5, 2008 Share Posted March 5, 2008 he is right where is the fetch_array function being called ??? Link to comment https://forums.phpfreaks.com/topic/94447-fatal-error-call-to-a-member-function-on-a-non-objectgotta-hate-it/#findComment-483696 Share on other sites More sharing options...
Todd88 Posted March 10, 2008 Author Share Posted March 10, 2008 I used a similiar method for a different section of the site but it doesn't work for this one. Here is the code for the other section: $sql=$Db1->query("SELECT clicked_today, SUM(clicked_today) FROM user GROUP BY permission"); $clickstoday=$Db1->fetch_array($sql); It works this way Link to comment https://forums.phpfreaks.com/topic/94447-fatal-error-call-to-a-member-function-on-a-non-objectgotta-hate-it/#findComment-488105 Share on other sites More sharing options...
uniflare Posted March 10, 2008 Share Posted March 10, 2008 you can debug classes with: var_dump($Db1); this will list functions and variables i believe Link to comment https://forums.phpfreaks.com/topic/94447-fatal-error-call-to-a-member-function-on-a-non-objectgotta-hate-it/#findComment-488106 Share on other sites More sharing options...
KrisNz Posted March 10, 2008 Share Posted March 10, 2008 Is there a point in your script (or an included script) where you create an instance of your database class and assign it to $Db1? e.g $Db1 = new Database(); Link to comment https://forums.phpfreaks.com/topic/94447-fatal-error-call-to-a-member-function-on-a-non-objectgotta-hate-it/#findComment-488115 Share on other sites More sharing options...
Todd88 Posted March 10, 2008 Author Share Posted March 10, 2008 I finally got it to work! Thanks guys Link to comment https://forums.phpfreaks.com/topic/94447-fatal-error-call-to-a-member-function-on-a-non-objectgotta-hate-it/#findComment-488139 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.