Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CGI

Status
Not open for further replies.

samesale

Programmer
Sep 15, 2003
133
US
I have written the following program. However, it gives me error: syntax error at carsearch2.cgi line 77, near "print" Execution of carsearch2.cgi aborted due to compilation errors. could not fire up

#!/usr/bin/perl

print "Content-type:text/html\n\n";

use CGI;
$query = new CGI;

#carsearch.cgi - use with car.html and car.cgi and car.out - car for Sale

print "<h2>Cars For Sale</h2>\n";

# First we initialize some counters and hashes for storing the
# summarized data.
$count =0;
$commentary ="";
$count++;
$d ="\$";

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);

%FORM = ();

foreach $pair (@pairs) {
$pair =~ s/\+/ /g;

($name, $value) = split(/=/, $pair);

$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c", hex($1))/eg;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c", hex($1))/eg;
$value =~ s/\n/ /g; # replace newlines with spaces
$value =~ s/\r//g; # remove hard returns
$value =~ s/\cM//g; # delete ^M's

$FORM{$name} = $value;
print "$name\n";
}

eval {
open(GUEST, "<car.out") or dienice("Couldn't open auto.out for reading: $! \n");
while (<GUEST>) {
chomp;
($name,$add,$city,$state,$zip,$make,$photo,$model,$color,$mile,
$eyear,$price,$email,$tele,$time,$comment1,$month,$day,$year)=split/\|/;


# this is the same as $count = $count + 1;


if ($photo eq 'Yes') {
print "<table width=\"100%\">\n";
print "<tr bgcolor=\"red\"><th width=\"130\">Picture <font size=\"1\" color=\"green\">(to enlarge: right click the picture, then view image)</font></th><th>Year</th><th>Make</th><th>Model</th><th>Color</th><th>Miles</th>\n";
print "<th>Price</th><th>E-Mail</th><th>Tele.</th><th>Time-to-Call</th></tr>\n";
print "<td rowspan=\"2\">\n";
print "<bgcolor=\"pink\">\n";
print "<img src=\"/images/$tele.jpg\" width=\"130\" height=\"90\" align=\"left\" vspace=\"0\" hspace=\"0\"></td>\n";

print "<td align=\"left\" width=\"50\">$eyear</td><td align=\"left\" width=\"65\"><font color=\"blue\"> $make </font></td><td align=\"left\" width=\"65\">$model</td><td align=\"left\" width=\"55\">$color</td><td align=\"left\" width=\"60\">$mile</td>\n";
print "<td align=\"left\" width=\"50\">$d$price</td><td align=\"left\" width=\"80\"><a href=\"mailto: $email\" >$email </a></td><td align=\"left\" width=\"80\">$tele</td><td align=\"left\" > $time</td>\n";
print "<tr align=\"left\" valign=\"top\" bgcolor=\"#FF99FF\"> <td align=\"left\" colspan=\"7\" >$comment1</td>\n";
print "<td align=\"left\" colspan=\"2\"><font color=\"blue\">CODE#$tele $month-$day-$year</font></td></tr></table>\n";
}

if ($photo eq 'No') {
print "<table width=\"100%\">\n";
print "<tr bgcolor=\"red\"><th>Year</th><th>Make</th><th>Model</th><th>Color</th><th>Miles</th>\n";
print "<th>Price</th><th>E-Mail</th><th>Telephone</th><th>Time-to-Call</th></tr>\n";
print "<td align=\"left\" width=\"50\">$eyear</td><td align=\"left\" width=\"65\"><font color=\"blue\"> $make </font></td><td align=\"left\" width=\"50\">$model</td><td align=\"left\" width=\"50\">$color</td><td align=\"left\" width=\"50\">$mile</td>\n";
print "<td align=\"left\" width=\"50\">$d$price</td><td align=\"left\" width=\"50\"><a href=\"mailto: $email\" >$email </a></td>
<td align=\"left\" width=\"50\">$tele</td><td align=\"left\" width=\"50\"> $time</td>\n";
print "<tr align=\"left\" valign=\"top\" bgcolor=\"#FF99FF\"> <td align=\"left\" colspan=\"7\" >$comment1</td>\n";
print "<td align=\"left\" colspan=\"2\"><font color=\"blue\">CODE#$tele $month-$day-$year</font></td></tr></table>\n";
}
}
}

print <<EndHTML;
EndHTML

sub dienice {
my($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
}

Any help will be appreciate.
 
include this line at the styart of your script

use CGI::Carp (fatalsToBrowser);

drop the print<< statement as its not doing anything, and drop the dienice sub

and you should be good to go

HTH
--Paul
 
do EXACTLY as Paul says and output becomes:-

Code:
Content-type:text/html

<h2>Cars For Sale</h2>

... perfect!


Kind Regards
Duncan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top