Solved

What is causing this error?

Posted on 2013-06-08
4
296 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
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 82

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 108

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now