I am looking for ideas here. The problem is thus:

I have an MS-SQL database that contains information about people--name, phone, address, ID, etc. I connect to it via a Win32::ODBC connection to return demographic information. Everything works, but the image display is sloppy and I don't like sloppy.

Images (jpgs) are stored in outside the SQL server in a separate folder on the webserver. (There is no OLE field available in the database to place link info.) They are named according the the person's ID. For example John Doe would have the ID "DOEJ" and his image file would be "DOEJ.jpg".The image link is built dynamically in my Perl script and inserted into the HTML display by concatenating the src link with the ID pulled from the data base. Unfortunately, not all the people have photos. The script builds the link and passes it to the browser which displays a broken image icon when there is no picture behind the seemingly legitimate link.

Ideally, I'd like to be able to catch the problem before the data is sent to the browser and substitute a "no picture available for this person" message or image for the broken image link. I'm uncertain of the best approach for this, so I'm tossing it out here for the creative minds of the monastery. How and where can I test to see if there's an image in the image folder before I build the link from the ID data?

WB


In reply to CGI-SQL-HTML-Display "no image" by WhiteBird

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.