Solved

What is causing this error?

Posted on 2013-06-08
4
308 Views
Last Modified: 2013-06-10
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

0
Comment
Question by:brucegust
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 17

Assisted Solution

by:OmniUnlimited
OmniUnlimited earned 167 total points
ID: 39232447
getimagesize() requires that the url be encoded.  You have a space in the filename.  Try using url's like http://www.countryshowdown.com/Photos/Sarah%20Anderson.jpg instead of http://www.countryshowdown.com/Photos/Sarah Anderson.jpg.  Make line 55 like the following:

$photo_url = urlencode(str_replace("+", " ", $row['url']));

Open in new window

0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 167 total points
ID: 39232463
I always get rid of the spaces so I don't have that problem.
0
 
LVL 110

Assisted Solution

by:Ray Paseur
Ray Paseur earned 166 total points
ID: 39235090
0
 

Author Comment

by:brucegust
ID: 39235236
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!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question