Reply to Re: Retrieving an Image if Condition Not Met

Your name:

Reply:


Posted by tim on 05/21/06 20:49

Pete wrote:
> I'm sure the answer is simple, but the solution is eluding me-I'm
> not too good at the particulars of scripting. Maybe someone can point
> me on the right path...
>
> Here is the problem:
>
> I have a string of php code that retrieves an image, in this case, an
> image of a book cover from Amazon.com. This works perfectly well,
> unless, there isn't an image of the book on Amazon's server. When
> there's no image, a blank hole appears on the final page. What I
> would like to happen is, if the variable for the image isn't met
> (i.e. no book cover image), a "No Image" image, from my server,
> will load in its place.
>
> Here is the code that retrieves the image:
>
> <img border="0" src=<? echo $i['ImageUrlSmall'];?>>
>
> Is there a way to include a command that will retrieve an image from
> http://www.mysite.com/images/noimage.gif if the first condition is not
> met?
>
> If anyone can help me, I'd be grateful.
>
> --Pete

The condition is whether the file exists on amazons server.

One way to do check this is send a HTTP Head request to amazon's server
for the file, if the status code in the response is 200 then the file
exists at that location.

The php manual page for fsockopen will help you do it

Tim

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация