Jump to content

Recommended Posts

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;
}

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.