seany123 Posted May 1, 2009 Share Posted May 1, 2009 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 https://forums.phpfreaks.com/topic/156462-solved-help/ Share on other sites More sharing options...
the182guy Posted May 1, 2009 Share Posted May 1, 2009 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 https://forums.phpfreaks.com/topic/156462-solved-help/#findComment-823841 Share on other sites More sharing options...
Ken2k7 Posted May 1, 2009 Share Posted May 1, 2009 <?php if($profile['avatar'] == "") { echo "[ AVATAR ]"; } else { echo "<img src='{$profile->avatar}' width='82' height='82' style='border: 1px solid #cccccc'>"; } ?> Link to comment https://forums.phpfreaks.com/topic/156462-solved-help/#findComment-823859 Share on other sites More sharing options...
seany123 Posted May 1, 2009 Author Share Posted May 1, 2009 <?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 https://forums.phpfreaks.com/topic/156462-solved-help/#findComment-823866 Share on other sites More sharing options...
Ken2k7 Posted May 1, 2009 Share Posted May 1, 2009 seany123, read everyone's reply. Is $profile an array or an object? var_dump($profile); Link to comment https://forums.phpfreaks.com/topic/156462-solved-help/#findComment-823868 Share on other sites More sharing options...
seany123 Posted May 1, 2009 Author Share Posted May 1, 2009 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( "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 https://forums.phpfreaks.com/topic/156462-solved-help/#findComment-823870 Share on other sites More sharing options...
Ken2k7 Posted May 1, 2009 Share Posted May 1, 2009 <?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 https://forums.phpfreaks.com/topic/156462-solved-help/#findComment-823871 Share on other sites More sharing options...
seany123 Posted May 1, 2009 Author Share Posted May 1, 2009 ken your an amazing help ty! Link to comment https://forums.phpfreaks.com/topic/156462-solved-help/#findComment-823875 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.