Solved

What is causing this error?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…

862 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

23 Experts available now in Live!

Get 1:1 Help Now