Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

What is causing this error?

Head out to http://www.hihatwebdesign.com/Showdown/album_view.php?album_name=Contestants. You'll see with several pictures I'm getting an error and I don't know why.

Compare the same page to http://www.countryshowdown.com/album_view.php?album_name=Contestants and there's no error at all.

The error is getimagesize(http://www.countryshowdown.com/Photos/Ashley Headshot.jpg) [function.getimagesize]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/content/09/6568309/html/hihatwebdesign.com/Showdown/album_gallery_view.php on line 60

I've attached my code. Could someone tell me where I'm blowing it?

<?php
//here's my resizing function

//declare your variables

function sweet_imgResize($width, $height, $target) {
//takes the larger size of the width and height and applies the formula. Your function is designed to work with any image in any size.
if ($width > $height) {
$percentage = ($target / $width);
} else {
$percentage = ($target / $height);
}

//gets the new value and applies the percentage, then rounds the value

$width = round($width * $percentage);
$height = round($height * $percentage);
//returns the new sizes in html image tag format...this is so you can plug this function inside an image tag so that it will set the image to the correct size, without putting a whole script into the tag.
//echo "width=\"$width\" height=\"$height\"";
return "width=\"$width\" height=\"$height\"";

}

?>

<?php
$maxcols = 4; 
include ("carter.inc");
$cxn = mysqli_connect($host,$user,$password,$database)
or die ("couldn't connect to server");

$query = "select * from photos where album_name = '$the_album_name' order by photo_date";
$result = mysqli_query($cxn, $query)
or die ("Couldn't execute query.");

$count=0; // initialize count

while ($row=mysqli_fetch_assoc($result))
{
$count++; // increment count

if ($count == 1)
 { // initalize table
?>

	<table width="585" border="0" align="center" cellspacing="1" cellpadding="1">
	<tr>

<?php
 }
?>

	<td align="center">
	<?php
	$photo_url = str_replace("+", " ", $row['url']);
	$photo_id = $row['id'];
	?>

	<?php
	$mypicture = getimagesize("http://www.countryshowdown.com/Photos/$photo_url");
	?>
	<A HREF="album_viewer_kickoff.php?album_name=<?php echo $the_album_name; ?>&photo_id=<?php echo $photo_id; ?> "><img src="http://countryshowdown.com/thumbs/<?php echo $photo_url; ?>" <?php echo sweet_imgResize($mypicture[0],  $mypicture[1], 100); ?> 
	border="0" alt="<?php echo $row['description']; ?>">
	</a>
	</td>

<?php
if ($count % $maxcols == 0)
 { // if modulus of count is = 0 then end row
 ?>
 </tr><tr><td colspan="4">&nbsp;<BR></td><tr>
<?php 
 }

}

if ($count)
{ // data exists
 $fill = ($count % $maxcols); // current column
if ($fill){ // if not last column already fill in blank columns
for ($i = $fill; $i <= ($maxcols -1); $i++){
echo "<td>&nbsp;</td>";
}
echo "</tr>";
 }
 echo "</table>";
}
?>

Open in new window

SOLUTION
Avatar of OmniUnlimited
OmniUnlimited
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bruce Gust

ASKER

Yeah, I know...

Even after implementing the OminUnlimited's suggestion, I was still running into troubles. So what I did was apply the collabrative wisdom of this thread and went back and renamed the photos that weren't showing up properly and I got it done.

Thanks, Ray and everybody else. Page looks good now!