Jump to content

Call to a member function fetch_assoc() on a non-object


Mod-Jay

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.