Page 1 of 1

replace broken image with generic logo

Posted: Tue Jul 27, 2004 10:06 am
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

Posted: Tue Jul 27, 2004 10:27 am
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

Posted: Tue Jul 27, 2004 10:37 am
by SJanis
thank you very much...i really appreciate it