Gossamer Forum
Home : General : Perl Programming :

HTML won't run in IF statement stops at{

Quote Reply
HTML won't run in IF statement stops at{
Can anyone spot what am I doing wrong here please?

#!c:\perl\bin\perl.exe
use CGI ":standard";
$Dog=param("Dog");
$Cat=param("Cat");
$Goldfish=param("Goldfish");
If
($choice eq $Dog)
{
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

}

This is the error message which refers to the { } so am I not alowed to do this? ANY suggestions please

Chris



[Wed Jan 14 09:45:22 2004] [error] [client 127.0.0.1] Premature end of script headers: choice.pl
[Wed Jan 14 09:45:22 2004] [error] [client 127.0.0.1] syntax error at C:/Program Files/Apache Group/Apache2/cgi-bin/choice.pl line 8, near ")
[Wed Jan 14 09:45:22 2004] [error] [client 127.0.0.1] {"
[Wed Jan 14 09:45:22 2004] [error] [client 127.0.0.1] syntax error at C:/Program Files/Apache Group/Apache2/cgi-bin/choice.pl line 27, near "}"
[Wed Jan 14 09:45:22 2004] [error] [client 127.0.0.1] Execution of C:/Program Files/Apache Group/Apache2/cgi-bin/choice.pl aborted due to compilation errors.
Quote Reply
Re: [Silver Machine] HTML won't run in IF statement stops at{ In reply to
Where is '$choice' coming from?

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Silver Machine] HTML won't run in IF statement stops at{ In reply to
How about something like this? Is this more what you are trying to do?

Code:
#!c:\perl\bin\perl.exe

use strict;

use CGI ":standard";
my $IN = new CGI;

my $choice = $IN->param("choice");

if ($choice eq 'Dog') {

print $IN->header();

print qq|

<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>

|;

} elsif ($choice eq 'Cat') {

print $IN->header();

print qq|

<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>

|;

} else {

print $IN->header();

print qq|

<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>

|;

}

...and call with script_name.cgi?choice=Cat or script_name.cgi?choice=Dog ... etc.

This script is untested, but should work :)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] HTML won't run in IF statement stops at{ In reply to
Thanks I discovered it was "If" rather than "if" stopping it running that works great now, but I have posted a new thread about the latest problem! the dbi wont work with it! Chris
Post deleted by fuzzy logic In reply to