Hi all,
On my web page I have a search function that searches my database for relative matches. I have pictures associated with each item in the database stored in my images directory on the server. The search calls a CGI script that displays the contents of the database relavent to the search and it needs to look in my images directory to see if the image exists. If the images exists i want to display that image, but if it does not, then I have a default image I want to display. I create the path out of variables to use in a "if" statement.
my $path="http://servername.com/username/images/";
my $imagename="filename.jpg";
my $imagedefault="default.jpg";
if ( -e '$path.$imagename'){
print "<"."code><td><IMG SRC=."$path.$imagename."></td></code".">";
}
else
{
print "<" . "code><td><IMG SRC=".$path.$imagedefault."></td></code" ."
+>";
}
I have verified that the images will print, and I have printed out the path from the variables and that it correct by doing.
print $path.$imagedefault;
And this displays the exact path that I use in the IMG tag and and the images displays just fine.
The problem is that: if
( -e '$path.$imagename') does not see that the file exists, so it always uses the default images, even if an image exists.
So, I am running everything from the same server and I have a CGI script trying to chack that a files exists. How can I do this? I have tried everything I can think of and it appears that I am doing what other threads have suggested, but no luck.
Thanks in advance!!!!
20031210 Edit by Corion: Added code tags
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.