Is there something I have missed out here as now the HTML bit works and the DBI bit works but not together. The Goldfish page loads when I am asking for DOG! I dont get any error messages. I have tried adding
#!c:\perl\bin\perl.exe
use CGI ":standard";
use DBI;
my $IN = new CGI;
my $choice = $IN->param("choice");
no avial I am putting this togeter bit by bit and want to only access the database once depending on what variable is sent from the previous page, This is what $choice is and will be Dog Cat or Goldfish.
Any more ideas please I am new at this! Chris
#!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
}
#!c:\perl\bin\perl.exe
use CGI ":standard";
use DBI;
my $IN = new CGI;
my $choice = $IN->param("choice");
no avial I am putting this togeter bit by bit and want to only access the database once depending on what variable is sent from the previous page, This is what $choice is and will be Dog Cat or Goldfish.
Any more ideas please I am new at this! Chris
#!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
}