gastooon Posted June 2, 2011 Share Posted June 2, 2011 Hello! My problem is that in my forum I want to display the picutre of their user and if they do not have a picture I want to show the standard one. I got all of this working on another part of the page but for some reason I can only get it to display the standard picture and not their custom picture... The code looks like this: <?php // Now query any responses out of the database and place in a dynamic list $sqll = mysql_query("SELECT id FROM myMembers"); while($row = mysql_fetch_array($sqll)){ $id = $row["id"]; $check_pic = "..//members/$id/image01.jpg"; $default_pic = "..//members/0/image01.jpg"; if (file_exists($check_pic)) { $user_pic = "<img src=\"$check_pic\" align=\"left\" width=\"80px\" border=\"0\" />"; // forces picture to be 120px wide and no more } else { $user_pic = "<img src=\"$default_pic\" align=\"left\" width=\"80px\" border=\"0\" />"; // forces default picture to be 120px wide and no more } } $all_responses = ""; $sql = mysql_query("SELECT * FROM forum_posts WHERE otid='$thread_id' AND type='b'"); $numRows = mysql_num_rows($sql); if ($numRows < 1) { $all_responses = '<div id="none_yet_div">No respond has been posted yet.</div>'; } else { while($row = mysql_fetch_array($sql)){ $reply_author = $row["post_author"]; $reply_author_id = $row["post_author_id"]; $date_n_time = $row["date_time"]; $convertedTime = ($myAgoObject -> convert_datetime($date_n_time)); $whenReply = ($myAgoObject -> makeAgo($convertedTime)); $reply_body = $row["post_body"]; $all_responses .= '<div class="response_top_div">Re: ' . $thread_title . ' | ' . $whenReply . ' <a href="../profile.php?id=' . $reply_author_id . '">' . $reply_author . '</a> said:</div> <div class="response_div" style="padding-left:20px; vertical-align:text-top;">' . $user_pic . ' <div style="padding-left:117px;"> ' . $reply_body . '</div></div>'; } } ?> Please help me if you can! Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/238189-picture-in-forum/ Share on other sites More sharing options...
runnerjp Posted June 2, 2011 Share Posted June 2, 2011 Hello, Lokking at your code i can see ur path is incorrect $check_pic = "..//members/$id/image01.jpg"; $default_pic = "..//members/0/image01.jpg"; It should be $check_pic = "../members/$id/image01.jpg"; $default_pic = "../members/0/image01.jpg"; Quote Link to comment https://forums.phpfreaks.com/topic/238189-picture-in-forum/#findComment-1223979 Share on other sites More sharing options...
gastooon Posted June 2, 2011 Author Share Posted June 2, 2011 ohh didn't see that myself but it didn't change a thing :/ still only show the standard picture .. Quote Link to comment https://forums.phpfreaks.com/topic/238189-picture-in-forum/#findComment-1223980 Share on other sites More sharing options...
runnerjp Posted June 2, 2011 Share Posted June 2, 2011 First of all i would check that it is getting the row ID. $id = $row["id"]; echo $id; Quote Link to comment https://forums.phpfreaks.com/topic/238189-picture-in-forum/#findComment-1223983 Share on other sites More sharing options...
gastooon Posted June 2, 2011 Author Share Posted June 2, 2011 Yes it's getting the id, echo worked perfectly Quote Link to comment https://forums.phpfreaks.com/topic/238189-picture-in-forum/#findComment-1223990 Share on other sites More sharing options...
runnerjp Posted June 2, 2011 Share Posted June 2, 2011 Ok now try setting your default picture as members/$id/image01.jpg to see if this pics up the image... Quote Link to comment https://forums.phpfreaks.com/topic/238189-picture-in-forum/#findComment-1224059 Share on other sites More sharing options...
gastooon Posted June 2, 2011 Author Share Posted June 2, 2011 Now I don't follow, you want me to put the default picture in the $id folder? why do that ? the picture isn't the problem cause have tried with several diffrent accounts. Quote Link to comment https://forums.phpfreaks.com/topic/238189-picture-in-forum/#findComment-1224101 Share on other sites More sharing options...
runnerjp Posted June 2, 2011 Share Posted June 2, 2011 because we are checking if the file exists because at the moment it seems to not be there! If you can display the image just stand alone then we know its there and working! Quote Link to comment https://forums.phpfreaks.com/topic/238189-picture-in-forum/#findComment-1224188 Share on other sites More sharing options...
gastooon Posted June 2, 2011 Author Share Posted June 2, 2011 I replaced the picture and it doesn't show me anything then , it feels like it doesn't know in which id it should pick it from even tough it should Quote Link to comment https://forums.phpfreaks.com/topic/238189-picture-in-forum/#findComment-1224213 Share on other sites More sharing options...
runnerjp Posted June 6, 2011 Share Posted June 6, 2011 I thought that was the issue thats why i was checking the picture Seems like its 2 thinks 1) check the path of your image ... is it correct? .. does it have the image in there?? 2) right click on the html output and go to properties and copy the address url <- it might not show the user id! Quote Link to comment https://forums.phpfreaks.com/topic/238189-picture-in-forum/#findComment-1225796 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.