Jump to content

[SOLVED] HELP - object of type mysqli_result as array error


widget

Recommended Posts

HI, Im having an error with the following page.

 

Using php 5

 

Any help would be much appreciated.

 

ERROR:

Fatal error: Cannot use object of type mysqli_result as array in /home/kabooc/public_html/user_profile.php on line 41

 

If I comment out the snippet below the page displays fine.

 

ERROR CODE SNIPPET: lines 39 to 44

$mailSettings = $members_profiles[mail_settings];
$mailSettingsArray = array(
"<a href=mail_send.php?game=$game&send_to=$usersOn[username]><img src=images/icons/mail.gif></a>",
"<a href=mail_send.php?game=$game&send_to=$usersOn[username]><img src=images/icons/mail.gif></a>",
"");
$mailSettings = $mailSettingsArray[$mailSettings];

 

FULL PAGE CODE:

 

<?php
$rank_check = 1;
$page_title = "User Profile";
include "header.inc.php";
$db_server   = "localhost";
$db_username = "#######";
$db_password = "#######";
$db_name     = "#######";
$con=mysqli_connect($db_server,$db_username,$db_password);
mysqli_select_db($con,$db_name);

$members = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$members_profiles = fetch("SELECT * FROM members_profiles2 WHERE username = '$user' AND game = '$game'");
$profile_id = fetch("SELECT id FROM `members2` WHERE username = '$members[username]'");


$online = fetch("SELECT last_visit FROM online WHERE userid = '$members[id]' ORDER BY last_visit DESC LIMIT 1");

if ($rank >= "5")
{
$iplog = fetch("SELECT ip_addr FROM ip_log WHERE userid = '$members[id]' ORDER BY id DESC LIMIT 1");
$membersIP = " ($iplog[ip_addr])";
}
if (!$members[id])
{
die("$openHTML<p align=center class=error>That is not a real user</p>$closeHTML");
}


if ($members[rank] <= 1)
{
die("$openHTML<p align=center class=error>This user has been suspended.</p>$closeHTML");
}

$gender = $members_profiles[gender];
$genderArray = array("<img src=images/icons/undecided.gif>", "<img src=images/icons/female.gif>", "<img src=images/icons/male.gif>");
$gender = $genderArray[$gender];

//$mailSettings = $members_profiles[mail_settings];
//$mailSettingsArray = array(
//"<a href=mail_send.php?game=$game&send_to=$usersOn[username]><img src=images/icons/mail.gif></a>",
//"<a href=mail_send.php?game=$game&send_to=$usersOn[username]><img src=images/icons/mail.gif></a>",
//"");
//$mailSettings = $mailSettingsArray[$mailSettings];

$bud = "<a href=buds.php?game=$game&bud=$members[username]><img src=images/icons/bud.gif></a>";

$date_registered = date("M j, Y", $members_profiles[date_registered]);
$last_visited = date("H:i", $online[last_visit]);
$last_visited2 = date("M j, Y @ H:i", $online[last_visit]);

$exBday = explode("-", $members_profiles[birthday]);

$months = array("", "January", "February", "March", "April", "May", "June", "July", "August", "Septemeber", "October", "November", "December");

$bdayMonth = $exBday[0];
if ($bdayMonth < 10) { $bdayMonth = ereg_replace("0", "", $bdayMonth); }

$exBday[0] = $months[$bdayMonth];

$birthday = "$exBday[0] $exBday[1], $exBday[2]";

$userAge = $this_year - $exBday[2];
if ($this_month < $exBday[0])
{
$userAge = $userAge - 1;
}
if (($this_month == $exBday[0]) && ($today < $exBday[1]))
{
$userAge = $userAge - 1;
}

if ($online[last_visit] >= ($timestamp - $secondsToKeepUsersOn))
{
$onlineNow = "<b><font color=green>Yes! <i><font size=-1>last visit at $last_visited</font></i></font></b>";
}
else
{
$onlineNow = "<B><font color=red>No <i><font size=-1>last visit on $last_visited2</font></i></font></b></font></b>";

if ($last_visited2 == "Dec 31, 1969 @ 18:00")
{
$onlineNow = "<B><font color=red><i><font size=-1>Never logged in</font></i></font></b></font></b>";
}
}

$yourNotes = fetch("SELECT bud_note FROM buds2 WHERE bud_me = '$userid' AND bud_you = '$members[id]'");
$yourNotes = $yourNotes[bud_note];
if (!$yourNotes) { $yourNotes = "<i>You do not have any notes on the player, add them to your buddy list to add notes!</i>"; }

$find_shop = fetch("SELECT shop_name,shop_size FROM usershops2 WHERE owner = '$members[id]' AND game = '$game'");
if ($find_shop[shop_name])
{
$usershop_line = "<b>Shop:</b> <a href=$base_url/usershop.php?game=$game&user=$user>$find_shop[shop_name]</a> <font size=-1>(size $find_shop[shop_size])</font>";
}

$find_gallery = fetch("SELECT gallery_name,gallery_size FROM usergallerys WHERE owner = '$members[id]' AND game = '$game'");
if ($find_gallery[gallery_name])
{
$gallery_line = "<br><b>Gallery:</b> <a href=$base_url/usergallery.php?game=$game&user=$user>$find_gallery[gallery_name]</a> <font size=-1>(size $find_gallery[gallery_size])</font>";
}

$find_deck = fetch("SELECT gallery_name,gallery_size FROM usercards WHERE owner = '$members[id]' AND game = '$game'");
if ($find_deck[gallery_name])
{
$deck_line = "<br><b>Card Deck:</b> <a href=$base_url/userdeck.php?game=$game&user=$user>$find_deck[gallery_name]</a> <font size=-1>(size $find_deck[gallery_size])</font>";
}

$locationLine = $members_profiles[location];
if (!$locationLine)
{
$locationLine = "<i>Middle of no where!</i>";
}

$getClub = fetch("SELECT position,club FROM club_members2 WHERE user = '$members[id]' AND game = '$game'");
$getclub = fetch("SELECT id,name FROM clubs2 WHERE id = '$getClub[club]' AND game = '$game'");
if ($getclub[id])
{
$clubrank = $getClub[position];
if ($clubrank == 1)
{
	$position = "Member";
}
if ($clubrank == 2)
{
	$position = "Moderator";
}
if ($clubrank == 3)
{
	$position = "Admin";
}
$club_line = "<br><b>Club:</b> $position in <a href=$base_url/club.php?game=$game&clubid=$getclub[id]>$getclub[name]</a>";
}



if ($act == "vote")
{

$limit1 = 21600;
$timeLimit = "6 Hours";

// Start Check

$checking = "profile_vote";
$limit = $timestamp - $limit1;

$findCheck = fetch("SELECT * FROM checking3 WHERE userid = '$userid' AND check_what = '$checking' AND timestamp > '$limit' AND game = '$game'");


if ($members[username] == $username)
{
die(header(error("user_profile.php?&user=$members[username]","You cannot vote for your own profile page!")));
}

// End Check

if ($findCheck[id])
{
die(header(error("user_profile.php?&user=$members[username]","You already voted, try again in $timeLimit hours!")));
}

if (!$findCheck[id])
{

$newvote = $members_profiles[vote]+1;
mysqli_query($con,"UPDATE members_profiles2 SET vote=$newvote WHERE username = '$user' AND game = '$game'");
mysqli_query($con,"DELETE FROM checking3 WHERE userid = '$userid' AND check_what = '$checking' AND game = '$game'");
mysqli_query($con,"INSERT INTO checking3 (userid,check_what,timestamp,game) VALUES ('$userid','$checking','$timestamp','$game')");
}
}

$hair = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$top = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$bottoms = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$shoes = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$shoes = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$eyes = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$lips = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$bg = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$clothes = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$socks = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$hat = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$acc = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$glasses = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$earings = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$necklace = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$skin = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$pet = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$lhand = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$rhand = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$mask = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");

$gender2 = $members_profiles[gender];

if ($gender2 == "1")
{
$body="bodyf";
}
if ($gender2 == "2")
{
$body="bodym";
}


?>
<style type="text/css">
<!--
#body {
background-image: url(/images/dd/<?=$body?>.png);
position:absolute;
width:150px;
height:300px;
z-index:1;
background-repeat: no-repeat;

}
#shoes {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$shoes[shoes]?>.png);
background-repeat: no-repeat;
}
#socks {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$socks[socks]?>.png);
background-repeat: no-repeat;
}
#top {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$top[top]?>.png);
background-repeat: no-repeat;
}
#bottoms {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$bottoms[bottoms]?>.png);
background-repeat: no-repeat;
}
#hair {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$hair[hair]?>.png);
background-repeat: no-repeat;
}
#eyes {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$eyes[eyes]?>.png);
background-repeat: no-repeat;
}
#lips {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$lips[lips]?>.png);
background-repeat: no-repeat;
}
#bg {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$bg[bg]?>.png);
background-repeat: no-repeat;
}
#clothes {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$clothes[clothes]?>.png);
background-repeat: no-repeat;
}
#hat {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$hat[hat]?>.png);
background-repeat: no-repeat;
}
#acc {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$acc[acc]?>.png);
background-repeat: no-repeat;
}
#glasses {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$glasses[glasses]?>.png);
background-repeat: no-repeat;
}
#earings {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$earings[earings]?>.png);
background-repeat: no-repeat;
}
#necklace {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$necklace[necklace]?>.png);
background-repeat: no-repeat;
}
#skin {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$skin[skin]?>.png);
background-repeat: no-repeat;
}
#lhand {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$lhand[lhand]?>.png);
background-repeat: no-repeat;
}
#rhand {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$rhand[rhand]?>.png);
background-repeat: no-repeat;
}
#pet {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$pet[pet]?>.png);
background-repeat: no-repeat;
}
#mask {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$mask[mask]?>.png);
background-repeat: no-repeat;
}
#bgacc {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$bgacc[bgacc]?>.png);
background-repeat: no-repeat;
}
#tatoo {
position:absolute;
width:150px;
height:300px;
z-index:1;
background-image: url(/images/dd/<?=$tatoo[tatoo]?>.png);
background-repeat: no-repeat;
}
-->
</style>
<?
echo $openHTML;
?>
<style type="text/css">
<!--
#Layer1 {
position:relative
width:680px;
height:auto;
z-index:1;
visibility: visible;
overflow: auto;
}
#Layer2 {
position:relative
width:680px;
height:400px;
z-index:1;
visibility: visible;
overflow: auto;
}
-->
</style>
<table width=100% border="0" align='center' cellpadding='10' bordercolor="#CCCCCC" bgcolor=#ffffff>
  <tr><td colspan='2' bgcolor='#FFFFFF'><table width='100%' border='0' cellspacing='0' cellpadding='10'><tr><td bgcolor='#FFFFFF'><div align='left'><FONT SIZE='+2'><B><?php echo $members[display_name]; ?>'s Profile</B></FONT><br>    
    </div>
             <a href=user_profile.php?&act=vote&user=<?php echo $members[username]; ?>>Vote for this profile page</a><br>
            Votes: <?php echo $members_profiles[vote]; ?> </td></tr></table>
      <table width='100%' border='0' align="center" cellpadding='10' cellspacing='0'>
        <tr>
          <td width="30%" rowspan="2" valign="top">
<div id="bg"></div>
<div id="bgacc"></div>
<div id="body"></div>
<div id="skin"></div>
<div id="tattoo"></div>
<div id="eyes"></div>
<div id="lips"></div>
<div id="socks"></div>
<div id="shoes"></div>
<div id="clothes"></div>
<div id="bottoms"></div>
<div id="top"></div>
<div id="glasses"></div>
<div id="earings"></div>
<div id="necklace"></div>
<div id="hair"></div>
<div id="mask"></div>
<div id="hat"></div>
<div id="acc"></div>
<div id="rhand"></div>
<div id="lhand"></div>
<div id="pet"></div>
</td>
          <td>
          </td>
        </tr>
        <tr>
          <td width='37%' valign='top' bgcolor='#FFFFFF' ><p align=left><b>Username:</b><br>
                <?php echo $members[display_name];$membersIP;?><br>
            <?php echo$membersIP?><br>
            <br>
            <b>Birthday:</b><br>
            <?php echo $birthday; ?> (<?php echo $userAge; ?> years old!)<br>
            <br>
            <b>Location:</b><br>
            <?php echo $locationLine; ?><br>
            <br>
                  <b>Date Registered:</b> <?php echo $date_registered; ?><br>
                  <br>
                  <b>Total Referrals:</b> <?php echo $members_profiles[referrals]; ?><br>
                  <br>
                  <b>Total Posts:</b> <?php echo $members[post_count]; ?><br>
                  <?
$result = mysqli_query($con,"SELECT * FROM trophy WHERE user_name = '$user'");
$num_rows = mysqli_num_rows($result);

echo "<br><b>Trophies:</b> $num_rows \n";
?>
                  <br>
                  <?
$result = mysqli_query($con,"SELECT * FROM usercards_items WHERE owner = '$members[id]'");
$num_rows = mysqli_num_rows($result);

echo "<br><b>Collectable Cards:</b> $num_rows \n";
?>
                  <?
$result = mysqli_query($con,"SELECT * FROM avatar_blank WHERE user_name = '$members[username]'");
$num_rows = mysqli_num_rows($result);

echo "<br><br><b>Secret Avatars:</b> $num_rows <Br><br>";
?>
            <b>Current Avatar:</b><br>
                  <?
$current_avatar = fetch("SELECT * FROM members_profiles2 WHERE username = '$members[username]' AND game = '$game'");

echo "<img src=\"$base_url/images/user_images/opg_1/avatars/$current_avatar[avatar].gif\" hspace=\"20\"><br>";


?>
                  <br>
                  <br>
          </p></td>
          <td width='37%' valign='top' bgcolor=#FFFFFF><p align=left><b>Your Notes:</b></p>
              <table width="100%" border="1" cellpadding="6" cellspacing="0" bordercolor="#CCCCCC" bgcolor="#FFFFFF">
                <tr>
                  <td><?php echo $yourNotes; ?></td>
                </tr>
              </table>
            <form action=buds.php?game=<?php echo $game; ?>&bud=<?php echo $members[username]; ?> method=post>
                <font size='-1'>
                <input type=submit value='Add to Buddy List'>
                </font>
              </form>
            <br>
              <p><?php echo $usershop_line; ?><br>
                  <br>
                  <?php echo $club_line; ?> <br>
                  <br>
                  <?php echo $gallery_line; ?><br>
                <br>
                  <?php echo $deck_line; ?></p>
            <p><b>Online?</b> <?php echo $onlineNow; ?><br>
              </p>
            <table>
                <tr>
                  <td><form action=mail_send.php?game=<?php echo $game; ?>&send_to=<?php echo $members[username];?> method=post>
                      <font size='-1'>
                      <input type=submit value='Send Mail'>
                      </font>
                  </form></td>
                </tr>
            </table></td>
        </tr>
      </table>
      <hr width=100% color='<?php echo $tableOutline; ?>'>
       <br>
       <div align="center"><b><?php echo $numUserPets; ?> <font size="2" face="Arial, Helvetica, sans-serif">Pets:</font></b>

<table> <tr><td><?

$query = mysqli_query($con,"SELECT * FROM user_pets2 WHERE owner = '$members[id]' AND adoption = '0' AND game = '$game' ORDER BY id");
$query2 = mysqli_query($con,"SELECT * FROM user_pets2 WHERE owner = '$members[id]' AND adoption = '0' AND game = '$game'");
$numQuery = mysqli_num_rows($query2);

$x = 0;
while ($array = mysqli_fetch_array($query))
{
$id = $array[id];
$getPet = fetch("SELECT * FROM pets2 WHERE id = '$array[species]' AND game = '$game'");
$y = $x % 2;
if ($y == 0)
{
	echo "<table><tr width=100%>";
}

$image[$id] = "pet_$getPet[id]";

if ($array[wearing] != 0)
{
	$findLook = fetch("SELECT * FROM pet_looks WHERE change_from = '$array[species]' AND item_name = '$array[wearing]'");

	if ($findLook[id])
	{
		$image[$id] = "pet2_$findLook[id]";
	}
$array2 = fetch("SELECT * FROM user_pets2 WHERE owner = '$userid' AND adoption = '0' AND id = '$id' AND game = '$game'");


$petpetimage = "$array2[petpet]";	}

echo "
<td valign=top>
<p align=center>
<img src=$base_url/images/user_images/opg_$game/pets/$image[$id].gif>
<!-- <img src=$base_url/images/user_images/opg_$game/petpets/$petpetimage.gif border=1>-->
<br><a href=user_pets.php?id=$array[id]&game=$game><b>$array[name]</b> the $getPet[name]!</a></p>
</td>";

$x++;
}

if ($x == 0)
{
print "<tr><td><p align=center><i>This user has no pets!</i></p></td></tr>";
}

echo "</table></center>";
?>  </td></tr></table>     </div>
       <br>
       <hr width=100% color='<?php echo $tableOutline; ?>'>
<tr>
<tr><td>
  <div align="center"><b><font size="2" face="Arial, Helvetica, sans-serif">Trophy Case</font></b><br>
      <?php

$sql_query = "SELECT * FROM `trophy` WHERE `user_name` = '$members_profiles[username]' ORDER BY `trophy`.`trophy_id` ASC";
//store the SQL query in the result variable
$result = mysqli_query($sql_query);

$cols = 5;
$count = 0;

if(mysqli_num_rows($result))
{
        echo '<table cellpadding="2" width="100%">';
	//output as long as there are still available fields
while($row = mysqli_fetch_row($result))
{
            if ($count % $cols == 0) echo '<tr>';		     echo "<td><a href=http://www.chickapets.com/trophy/{$row[1]}.php><img src='$base_url/images/user_images/opg_1/trophy/{$row[1]}.gif'  border=0></a></td>";
            ++$count;
            if ($count % $cols == 0) echo '</tr>';
}

        if ($count % $cols != 0) echo '</tr>';
        echo '</table>';
}

else       //if no fields exist
{

print "This user has no Trophies!";



}
?>
<hr width=75% color='<?php echo $tableOutline; ?>'> </div></td>
</tr>
   <td width=100% valign=top bgcolor=#FFFFFF><div id="Layer1">  
   <p><?php echo $members_profiles[profile]; ?></p></div> </td>
</tr>
</table>
<hr width=75% color='<?php echo $tableOutline; ?>'>
<br>
<div id="Layer2"><?php
require('inc_rate.php');
getComments("$members[id]");
submitComments("$members[id]","$PHP_SELF");
?>
</div>
<?php echo $closeHTML; ?>

 

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.