Jump to content

image path issue


darkfreaks

Recommended Posts

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++;
}

}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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"];
		}
	}
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 } ?>

Link to comment
Share on other sites

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 however
Note 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?

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

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.