Gossamer Forum
Home : General : Databases and SQL :

IF STATEMENT "use" not allowed in expression at

Quote Reply
IF STATEMENT "use" not allowed in expression at
Is there something I have missed out here as now the HTML bit works and

the DBI bit works but not together. I get yards of error complaining
about every single bit of the HTML and this which I think is probably the

relevent bit! If i can not use USE how do I get in to my database? Any help pease Chris

syntax error at C:\Program Files\Apache Group\Apache2\cgi-bin\choice.pl

line 8, nea
r "{"
"use" not allowed in expression at C:\Program Files\Apache

Group\Apache2\cgi-bin
\choice.pl line 10, at end of line
syntax error at C:\Program Files\Apache Group\Apache2\cgi-bin\choice.pl

line 30, ne
ar "print "content"
Execution of C:\Program Files\Apache Group\Apache2\cgi-bin\choice.pl

aborted due to
compilation errors.


#!c:\perl\bin\perl.exe
use CGI ":standard";
$Dog=param("Dog");
$Cat=param("Cat");
$Goldfish=param("Goldfish");
if
($choice eq $Dog)
{
use DBI;
my $DBH = DBI->connect("DBI:mysql:Guide");
my $sth = $DBH->prepare( "SELECT Name FROM Dog" );
$sth->execute();
my $array_ref = $sth->fetchall_arrayref();
foreach my $row (@$array_ref)
{
my ( $Name,) = @$row;
print "\t;
}
$sth->finish();
$DBH->disconnect();

print "content-type:text/html\n\n";
print <<E_O_F;

<HTML>
<HEAD><TITLE>Dog</TITLE>
<BASEFONT FACE="Arial Black">
</HEAD>
<BODY>
<TABLE BORDER="0" ALIGN="center" WIDTH="75%" Height="75%">
<TBODY>
<TR><TD COLSPAN="100%" align="center"><H2>Dog:</H2></TD></TR>
</TBODY>
</TABLE>
</BODY>
</HTML>

E_O_F

}
elsif
($choice eq $Cat)
{
print "content-type:text/html\n\n";
print <<E_O_F;

<HTML>
<HEAD><TITLE>Cat</TITLE>
<BASEFONT FACE="Arial Black">
</HEAD>
<BODY>
<TABLE BORDER="0" ALIGN="center" WIDTH="100%" Height="100%">
<TBODY>
<TR><TD COLSPAN="100%" align="center"><H2>Cat:</H2></TD></TR>
</TBODY>
</TABLE>
</BODY>
</HTML>

E_O_F

}
else
{
print "content-type: text/html\n\n";
print <<E_O_F;

<HTML>
<HEAD><TITLE>Goldfish</TITLE>
<BASEFONT FACE="Arial Black">
</HEAD>
<BODY>
<TABLE BORDER="0" ALIGN="center" WIDTH="100%" Height="100%">
<TBODY>
<TR><TD COLSPAN="100%" align="center"><H2>Goldfish</H2></TD></TR>
</TBODY>
</TABLE>
</BODY>
</HTML>

E_O_F

}