Mod-Jay Posted August 22, 2011 Share Posted August 22, 2011 Random Error that im getting on my webhost, not localhost. Fatal error: Call to a member function fetch_assoc() on a non-object in /home/*****/index.php on line 127 Line 127: while ($premium = $row->fetch_assoc()) { Code: <div class="toplist-content"> <table cellspacing="0"> <tbody> <?php $row = $home->getList(1); while ($premium = $row->fetch_assoc()) { ?> <tr class="table"> <td class="name"><a href="server.html"> <h3> <?php echo ucfirst($premium['servername']); ?> </a> <font size='1.5'><?php echo ucfirst(substr($premium['serverdesc'],0,25)). "..."; ?> </h3> </font> </td> <td class="revision"><h3> <?php echo ucFirst($premium['revision']); ?> </h3></td> <td class="votes"><h3> <?php echo $premium['vote']; ?> </h3></td> <td class="status"><?php if($home->getStatus($premium['host'], $premium['port']) == true) { echo "<span class='ticket open'>Online</span>"; } else { echo "<span class='ticket closed'>Offline</span>"; } ?> </td> </tr> <?php } ?> </tbody> </table> </div> The getList() function : function getList($premium) { $query = $this->con->query("SELECT * FROM `".$this->prefix."servers` WHERE `premium` = '".$premium."' && `ban` = '0' ORDER BY (SELECT COUNT(*) FROM `".$this->prefix."votes` WHERE `serverId` = '".$this->prefix."servers.id') DESC") or die(mysqli_error()); return $query; } Quote Link to comment https://forums.phpfreaks.com/topic/245459-call-to-a-member-function-fetch_assoc-on-a-non-object/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 22, 2011 Share Posted August 22, 2011 Is the ->query() method the mysqli query method or part of some other database class? Quote Link to comment https://forums.phpfreaks.com/topic/245459-call-to-a-member-function-fetch_assoc-on-a-non-object/#findComment-1260703 Share on other sites More sharing options...
Mod-Jay Posted August 22, 2011 Author Share Posted August 22, 2011 I think its part of the mysqli method Quote Link to comment https://forums.phpfreaks.com/topic/245459-call-to-a-member-function-fetch_assoc-on-a-non-object/#findComment-1260705 Share on other sites More sharing options...
btherl Posted August 23, 2011 Share Posted August 23, 2011 If it's not an object, what is it? Can you use var_dump() to find out? Then trace it back through the code until you get back to where it's created (which isn't far), and see if it's a non-object the whole way. Quote Link to comment https://forums.phpfreaks.com/topic/245459-call-to-a-member-function-fetch_assoc-on-a-non-object/#findComment-1260734 Share on other sites More sharing options...
Mod-Jay Posted August 23, 2011 Author Share Posted August 23, 2011 Votes isnt in the db, I found the problem Quote Link to comment https://forums.phpfreaks.com/topic/245459-call-to-a-member-function-fetch_assoc-on-a-non-object/#findComment-1260738 Share on other sites More sharing options...
PFMaBiSmAd Posted August 23, 2011 Share Posted August 23, 2011 Does your actual code have the or die() on it? Even though the use of mysqli_error() is incorrect (you need the connection link in that or you need to use the OOP version of it), the code should have died when there was a query error. Quote Link to comment https://forums.phpfreaks.com/topic/245459-call-to-a-member-function-fetch_assoc-on-a-non-object/#findComment-1260740 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.