Jump to content

[SOLVED] help


seany123

Recommended Posts

using this query:

<?php
$query = $db->execute("select `id`, `username`, `registered`, `level`, `kills`, `deaths`, `hp`, `maxhp`, `rm`, `staff`, `ncolor`, `money`, `gender`, `quote`, `crimes_failed`, `crimes_sucess`, `avatar`, `last_active`, `prison`, `hospital`, `signature`, `rating`, `city_id` from `players` where `username`=?", array($_GET['id']));
$profile = $query->fetchrow();

 

i tried using this if statment and echo:

 

<?php
if($profile['avatar'] == "")
                    {
                    echo "[ AVATAR ]";
                    }
                    else
                    {
                    echo "<img src='$profile->avatar' width='82' height='82' style='border: 1px solid #cccccc'>";
                    }
                    ?>

 

now I know the page knows  what $profile->avatar is because on its echoing [AVATAR] when expected and trying to load a image when expected also.

 

but the image never opens i just get the unloaded image pic.

 

edit: i was thinking that maybe its because it needs to be profile['avatar'] instead of profile->avatar but ive tried and cant get it to work.

 

Link to comment
Share on other sites

First do a print_r($profile) to see what that contains. That will tell you if it is an object which needs $profile->avatar or it is an array.

 

Is fetchrow() correct? It's normally fetch_row()#

 

Also fetch_row() normally returns the result with numerical keys. Try fetch_assoc()

Link to comment
Share on other sites

<?php
if($profile['avatar'] == "")
                    {
                    echo "[ AVATAR ]";
                    }
                    else
                    {
                    echo "<img src='{$profile->avatar}' width='82' height='82' style='border: 1px solid #cccccc'>";
                    }
                    ?>

Link to comment
Share on other sites

<?php
if($profile['avatar'] == "")
                    {
                    echo "[ AVATAR ]";
                    }
                    else
                    {
                    echo "<img src='{$profile->avatar}' width='82' height='82' style='border: 1px solid #cccccc'>";
                    }
                    ?>

 

that didn't work either, it still wont display the image >.<

Link to comment
Share on other sites

seany123, read everyone's reply. Is $profile an array or an object?

 

var_dump($profile);

 

 

array(23) { ["id"]=>  string(1) "1" ["username"]=>  string(9) "adminsean" ["registered"]=>  string(10) "1220148866" ["level"]=>  string(3) "455" ["kills"]=>  string(2) "13" ["deaths"]=>  string(1) "0" ["hp"]=>  string(3) "630" ["maxhp"]=>  string(3) "630" ["rm"]=>  string(2) "14" ["staff"]=>  string(1) "5" ["ncolor"]=>  string(1) "0" ["money"]=>  string(9) "525057138" ["gender"]=>  string(4) "male" ["quote"]=>  string(8) "No Quote" ["avatar"]=>  string(59) "http://helios.gsfc.nasa.gov/image_euv_press.jpg" ["crimes_failed"]=>  string(3) "255" ["crimes_sucess"]=>  string(3) "581" ["last_active"]=>  string(10) "1241221272" ["prison"]=>  string(1) "0" ["hospital"]=>  string(1) "0" ["signature"]=>  string(11) "donkey KONG" ["rating"]=>  string(1) "0" ["city_id"]=>  string(1) "1" }

 

Link to comment
Share on other sites

<?php
if($profile['avatar'] == "")
                    {
                    echo "[ AVATAR ]";
                    }
                    else
                    {
                    echo "<img src='" . $profile['avatar'] . "' width='82' height='82' style='border: 1px solid #cccccc'>";
                    }
                    ?>

 

Get your types straight next time. :)

Link to comment
Share on other sites

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.