darkfreaks Posted June 20, 2012 Share Posted June 20, 2012 i am pretty sure this is the chunk of problem code causing the issue just can't figure out where.... $SQLImage="SELECT * FROM tblImages INNER JOIN tblModel ON tblImages.modelID = tblModel.modelID WHERE tblImages.modelID = '".$modelID."' AND tblImages.imageTypeID = '2' OR tblModel.modelStatus <>'Offline'"; $RecImage_query=mysql_query($SQLImage,$oConn) or die("Error: ". mysql_error(). " with query ". $query); $i=mysql_num_rows($RecImage_query)-1; if (($RecImage_query==0)) { } else { mysql_data_seek($RecImage_query,$i); $cnt=mysql_num_rows($RecImage_query); $cntCount=$cnt; $cnt1=0; $arcnt=1; $rndMax=$cnt; $str=","; $str1=","; while(!($cnt1==$cnt)) { mysql_data_seek($RecImage_query,$cnt1); $row=mysql_fetch_assoc($RecImage_query); $images[$arcnt]=$row["imageFile"]; $cnt1++;$arcnt++; } } Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/ Share on other sites More sharing options...
cpd Posted June 20, 2012 Share Posted June 20, 2012 From our perspective the code works perfectly as you haven't actually highlighted any issues, narrowed it down, or presented any data to suggest what the error is or how it's replicated... We can not help unless you explain, in detail, what the problem is. And by "we" I mean myself and possibly others. Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355656 Share on other sites More sharing options...
ultimatum Posted June 20, 2012 Share Posted June 20, 2012 What's the error you're getting? Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355667 Share on other sites More sharing options...
darkfreaks Posted June 21, 2012 Author Share Posted June 21, 2012 i am getting broken images and i can not figure out where it is happening. can someone look in the attached file and point out to me where 18632_.php Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355766 Share on other sites More sharing options...
Drummin Posted June 21, 2012 Share Posted June 21, 2012 Sorry I have not looked the attached file yet, but it seems you are just building an array of the image results. Wouldn't this be easier? <?php $SQLImage="SELECT * FROM tblImages INNER JOIN tblModel ON tblImages.modelID = tblModel.modelID WHERE tblImages.modelID = '".$modelID."' AND tblImages.imageTypeID = '2' OR tblModel.modelStatus <>'Offline'"; $RecImage_query=mysql_query($SQLImage,$oConn) or die("Error: ". mysql_error(). " with query ". $SQLImage); $images=array(); $cnt=mysql_num_rows($RecImage_query); if ($cnt>0){ while($row=mysql_fetch_assoc($RecImage_query)){ $images[]=$row["imageFile"]; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355824 Share on other sites More sharing options...
darkfreaks Posted June 21, 2012 Author Share Posted June 21, 2012 it runs alot better but still coming up with 3 broken images. Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355903 Share on other sites More sharing options...
The Little Guy Posted June 21, 2012 Share Posted June 21, 2012 have you looked at the src in the img tag in the html? Is it pointing to the correct location? Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355904 Share on other sites More sharing options...
darkfreaks Posted June 21, 2012 Author Share Posted June 21, 2012 no it is not. i checked with FF web developer it is pointing to models/content/$modelID/ instead of models/content/$modelID/image.jpeg thats why i was wondering is this a html issue or code issue? Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355905 Share on other sites More sharing options...
The Little Guy Posted June 21, 2012 Share Posted June 21, 2012 you would have to show us how you generate the img tag. Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355916 Share on other sites More sharing options...
Drummin Posted June 21, 2012 Share Posted June 21, 2012 Is $row["imageFile"] containing "models/content/$modelID/" without the image? I guess I don't understand how $images[]=$row["imageFile"]; ..can contain anything other than the path you specify in $row["imageFile"]. How are you using the $images array to show images? This more than likely is where the problem is. Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355920 Share on other sites More sharing options...
darkfreaks Posted June 21, 2012 Author Share Posted June 21, 2012 im the thing it is just $images[number here] to output the variable. Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355923 Share on other sites More sharing options...
The Little Guy Posted June 21, 2012 Share Posted June 21, 2012 We will probably need to see more than that. Cant really help you without the exact line Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355927 Share on other sites More sharing options...
darkfreaks Posted June 21, 2012 Author Share Posted June 21, 2012 echo "<td><a href='#' onClick=\"MM_swapImage('Limage','','../cms/models/content/$modelID/{$images[2]}',1)\"> <img src='../cms/models/content/$modelID/{$images[2]}' width='70' height='116' border='0'></a></td>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355928 Share on other sites More sharing options...
Drummin Posted June 21, 2012 Share Posted June 21, 2012 Remember arrays start with the key of zero and not one, so try. <?php if (isset($images[0])){ echo "<img src='../cms/models/content/$modelID/{$images[0]}' width='208'height='345' border='0'name='Limage' id='Limage'></td>"; }else{ ?> <td><img src="../images/spacer.gif" width="208" height="345" border="0"></td> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355929 Share on other sites More sharing options...
darkfreaks Posted June 21, 2012 Author Share Posted June 21, 2012 somthing is off about the image thing lena_02.jpg doesnt exist in cms/models/content/911 there is a M.O.2.jpg however Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355938 Share on other sites More sharing options...
Drummin Posted June 21, 2012 Share Posted June 21, 2012 Well it does seem to be a path issue and my last post was based on the model.php file you attached. there is a M.O.2.jpg howeverNote images should not have periods in their name. If below the code where you build the $images array you add (temporarily) <?php echo "<pre>"; print_r($images); echo "</pre>"; ?> What does the show? Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355946 Share on other sites More sharing options...
The Little Guy Posted June 21, 2012 Share Posted June 21, 2012 Note images should not have periods in their name. Yest they can. Lots of people do it. Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355948 Share on other sites More sharing options...
Drummin Posted June 21, 2012 Share Posted June 21, 2012 Note images should not have periods in their name. Yest they can. Lots of people do it. Well yes of course, but does it validate? Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355950 Share on other sites More sharing options...
darkfreaks Posted June 21, 2012 Author Share Posted June 21, 2012 for some reason the ID is not lining up with the correct images as far as i can tell Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355951 Share on other sites More sharing options...
Drummin Posted June 21, 2012 Share Posted June 21, 2012 1) Did you print the array as suggested? 2) Do you have image folders for each model named the modelID? 3) Have you verified that the images listed in the DB match those in the folder for this model? Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355953 Share on other sites More sharing options...
darkfreaks Posted June 21, 2012 Author Share Posted June 21, 2012 1.) yes 2.) i have images folders numbered for each ID 3.) i don't have DB acess i am doing this for a client however i could ask.but from what i can tell there appears to be a slight difference. Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355955 Share on other sites More sharing options...
Drummin Posted June 21, 2012 Share Posted June 21, 2012 It's hard to fix a relative path problem without knowing WHERE this file is listed compared to where the image is. As for testing a path, you should be able to hard code a line to see an image then use it as an example. <img src='../cms/models/content/$modelID/valid_image.jpg' width='208' height='345' border='0' name='Limage' id='Limage'> NOTE: I noticed some missing spaces with the line above. The issue was though, is the proper image(s) being loaded into the array, which is why I wanted you to print_r the $images array. You said you DID print the array. Is it holding what it should be? The key for the first image should be zero. Is it? Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355959 Share on other sites More sharing options...
darkfreaks Posted June 21, 2012 Author Share Posted June 21, 2012 yeah i get array(0=>'lena_02.jpg') however it hsould be outprinting 911 as the ID not zero. is there an easier way to just loop it for each folder? Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355961 Share on other sites More sharing options...
Drummin Posted June 21, 2012 Share Posted June 21, 2012 You've already defined the modelID with the variable $modelID. The $images array is just holding the images. So as a simple example you would do. <?php foreach($images as $image){ echo "<td><img src='../cms/models/content/$modelID/$image' width='70' height='116' border='0'></td>"; } ?> Or if you just want the first image <?php echo "<td><img src='../cms/models/content/$modelID/$images[0]' width='70' height='116' border='0'></td>"; ?> ******************** IS the issue that you have different models on this page, each with a different modelID? If that's the case then the whole approach should be different in building the array in the first place. Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355965 Share on other sites More sharing options...
darkfreaks Posted June 21, 2012 Author Share Posted June 21, 2012 so i can erase the image 0-2 BS and iput $images and it will display everything in the folder? Quote Link to comment https://forums.phpfreaks.com/topic/264531-image-path-issue/#findComment-1355968 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.