replace broken image with generic logo

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SJanis
Forum Newbie
Posts: 5
Joined: Tue Jul 27, 2004 10:06 am

replace broken image with generic logo

Post by SJanis »

i'm using the code <img src = "images/<?php echo $row_SubSearchDesc['itemImage']; ?>"> to pull a file name from a database such as "pic1.jpg" if this produces a broken image after it executes...is there anyway to write in an if statement for like the result to replace the broken image with something like "noimage.jpg" thank you very much in advance, i would greatly appreciate any help.
sean
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Code: Select all

if (file_exists($filename)) {
   // show the file
} else {
   // otherwise, just diplay generic image
}
http://se.php.net/manual/en/function.file-exists.php
SJanis
Forum Newbie
Posts: 5
Joined: Tue Jul 27, 2004 10:06 am

Post by SJanis »

thank you very much...i really appreciate it
Post Reply