iamsofuckingcool Posted October 2, 2009 Share Posted October 2, 2009 Hello, I am trying to display an image thumbnail that links to the image file. $maincontent .= "<br />\n<div id=\"result". $row['id'] ."\" class=\"result\">\n"; $img = compimg($row['id']); $thumb = compthumb($row['id']); $maincontent .= "<a href=\"$img\" rel=\"lightbox\"><img src=\"$thumb\" class=\"preview\" /></a>"; functions are //Returns the filename of the image for a specified post function compimg($id) { $files = glob("images/Posts/$id.*"); if ($files == false) return ''; if (!isset($files[0])) return ''; else return $files[0]; } //Returns the filename of the thumbnail for a specified post function compthumb($id) { $files = glob("images/Post_Thumbs/$id.*"); if ($files == false) return ''; if (!isset($files[0])) return ''; else return $files[0]; } the result is supposed to be href = "http://www.iasfc.com/images/48.gif src = "http://www.iasfc.com/iasfc.com/images/Post_Thumbs/48.gif" i keep getting: href = "http://www.iasfc.com/comment/iasfc.com/images/48.gif src = "http://www.iasfc.com/comment/iasfc.com/images/Post_Thumbs/48.gif" How do i eliminate the comment dirctory in the URL? Quote Link to comment Share on other sites More sharing options...
RussellReal Posted October 2, 2009 Share Posted October 2, 2009 change return $files[0]; to return str_replace('comments/','',$files[0]); thats the only thing I can see to fix that maybe glob somehow gets the 'comments/' or whatever but if its not THERE it hasta be somewhere else in your script Quote Link to comment Share on other sites More sharing options...
iamsofuckingcool Posted October 2, 2009 Author Share Posted October 2, 2009 Thanks for the quick response. Here is the whole shebang. does this help? <?php require_once('recaptchalib.php'); //include('compimg.php'); $comment = $_POST['comment']; if(!$comment){ $q = "SELECT * FROM `comps` WHERE `id` = '". $comp ."'"; $r = mysql_query($q); $voting_array = mysql_fetch_array(mysql_query("SELECT * FROM `votes` WHERE `ip`='$ip'")); $vote_explode = explode(',', $voting_array['comp_id']); foreach($vote_explode as $vote_ex){ $vote_ex = explode(":", $vote_ex); $compnum = $vote_ex[0]; $compvote = $vote_ex[1]; $compvotearray[$compnum] = $compvote; } if(mysql_num_rows($r) > 0){ while($row = mysql_fetch_array($r, MYSQL_ASSOC)){ // count the comments $commentsCountQuery = "select * from comments where comp_id=" . $comp; $commentsCountResult = mysql_query($commentsCountQuery); $commentsCount = mysql_num_rows($commentsCountResult); $maincontent .= "<br />\n<div id=\"result". $row['id'] ."\" class=\"result\">\n"; $img = compimg($row['id']); $thumb = compthumb($row['id']); $maincontent .= "<a href=\"$img\" rel=\"lightbox\"><img src=\"$thumb\" class=\"preview\" /></a>"; $maincontent .= stripslashes($row['message']) ."\n<br /><br />\n<div class=\"clear\"></div>\n"; $maincontent .= '<span class="sentBy"><span class="lside">('. $commentsCount .') comments </a></span>'; $maincontent .= '<a href="" class="commlink">IASFC #'. $row['id'] .'</a>'; if(!$compvotearray[$row['id']]){ $maincontent .= '<span id="vote_buttons'. $row['id'] .'" class="vote_buttons"> <span id="a1votes_count'. $row['id'] .'"> <a id=":'. $row['id'] .':1:'. $row['votes1'] .':'. $row['votes2'] .':" class="vote_up" title="'. $phrase1 .':'. $phrase2 .'" href="javascript:;"> '. $phrase1 .' ('. $row['votes1'] .')</a></span>'; $maincontent .= ' - <span id="a2votes_count'. $row['id'] .'"> <a id=":'. $row['id'] .':2:'. $row['votes1'] .':'. $row['votes2'] .':" class="vote_down" title="'. $phrase1 .':'. $phrase2 .'" href="javascript:;"> '. $phrase2 .' ('. $row['votes2'] .')</a> </span></span><br />'; } else { $maincontent .= '<span id="vote_buttons'. $row['id'] .'" class="vote_buttons voted"> <span id="a1votes_count'. $row['id'] .'"> '. $phrase1 .' ('. $row['votes1'] .')</span>'; $maincontent .= ' - <span id="a2votes_count'. $row['id'] .'" class="vote_buttons voted"> '. $phrase2 .' ('. $row['votes2'] .') </span></span><br />'; } Quote Link to comment Share on other sites More sharing options...
RussellReal Posted October 2, 2009 Share Posted October 2, 2009 ok judging from the code my post above should put an end to your woes Quote Link to comment Share on other sites More sharing options...
iamsofuckingcool Posted October 2, 2009 Author Share Posted October 2, 2009 nope that pesky "comment" dir is still showing up. Then as i was just typing that I realized that the actual page is is all on is comment.php So all this is going down on iasfc.com/comment.php I don't get it. Quote Link to comment Share on other sites More sharing options...
RussellReal Posted October 2, 2009 Share Posted October 2, 2009 change return $files[0]; to return str_replace('comments/','',$files[0]); thats the only thing I can see to fix that maybe glob somehow gets the 'comments/' or whatever but if its not THERE it hasta be somewhere else in your script lol I put "comments" instead of "comment" change: return str_replace('comments/','',$files[0]); to return str_replace('comment/','',$files[0]); Quote Link to comment Share on other sites More sharing options...
iamsofuckingcool Posted October 2, 2009 Author Share Posted October 2, 2009 Well sir. That did it. +1 internets for you my friend. Thanks. Quote Link to comment Share on other sites More sharing options...
iamsofuckingcool Posted October 2, 2009 Author Share Posted October 2, 2009 how do i mark this as solved? Quote Link to comment Share on other sites More sharing options...
cags Posted October 2, 2009 Share Posted October 2, 2009 When your viewing the thread theres a button/link at the bottom left corner. Quote Link to comment 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.