I'm working on a CGi page were I print out data from a txt file. The page must print out all the data an even an image associated with file. The scalar $name must produce an image instead of text. I have placed images in the cgi-bin with names that correlate with the variable data $name. When the page is displayed all the information shows but the image is broken. I view the source in the browser and it shows the image to be there but the image is not showing. If anyone can help me I would appreciate it.
Thank You,
Randy
Here is my code from the txt file:
BHW1234|Drill|Black and Decker cordless drill with soft case|$79.97
BHW222|Hammer|Stanley 16-Ounce AntiVibe curved claw steel hammer|$22.4
+9
BHW2054|Handsaw|Dewalt 15 in. Hand Saw with blade armor features Tough
+Coat|$18.97
BHW7048|Level|True Blue Empire level. Accuracy, durability and readabi
+lity with a Lifetime Warranty. |$49.97
BHW6034|Screwdriver|Klein #2 phillips screwdriver with electrical insu
+lstion.|$18.29
BHW9856|Tablesaw|Saw Stop all-purpose versatility, reliability and saf
+e.|$1500.00
Here is my code from the cgi file:
#!c:\Dwimperl\perl\bin\perl.exe
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use strict;
use warnings;
print "Content-type: text/html\n\n";
print "<html><body>";
print "<div align='center'>";
print "<h2>Bob's Hardware Tools</h2>";
print "<h3>Current Hardware</h2>";
open (HARDWARE, "inventory.txt") or die "Error opening file, $!";
print "<table border='2' cellpadding='5'>";
while(my $hardware = <HARDWARE>){
(my $sku,my $name,my $desc,my $price) = split/\|/,$hardware;
print "<tr>";
print "<td><img src='$name.jpg' width='200' height='150' /></td>"
+;
print "<td>$sku</td>";
print "<td>$desc</td>";
print "<td>$price</td>";
}
close HARDWARE;
print "</table></div>";
print "</body></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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.