Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Nothing show up in the browser

by mnlight (Scribe)
on Jan 25, 2002 at 09:55 UTC ( [id://141434]=perlquestion: print w/replies, xml ) Need Help??

mnlight has asked for the wisdom of the Perl Monks concerning the following question:

Why does does the form not show up in the browser? everything before the form prints to screen nothing after.
#!/usr/bin/perl -w #Volunteer.pl - Sign up sheet for Volunteers use strict; use DBI; use CGI; my $query = CGI::new(); print $query->header(); print $query->start_html (-title=>'Volunteer SignUp Form', -link=>'#FFFFFF', -vlink=>'99FF99', -alink=>'black', -style=>{'-src'=>'/CSS/stylesheet.css'}); print $query->h1({-align=>'center'},'1990 MNLIGHTNING SIGNUP SHEET'); print $query->h2({-align=>'center'},'To sign up for a time simply sele +ct the botton indicating if you are the players Mother or Fath er. Only Parents can sign up. Other volunteers must sign up as the pa +rents so we know who is responsible to work those days. Select the dates you are available to work. Submit the information and + verify the choices are correct.'); print $query->start_form('POST', './Signup.pl'); print $query->center( $query->radio_group( -name =>'Parent', -value =>['Mother', 'Father'], -default=>'Mother', -linebreak=>'true')), $query->start_table({-align=>'center'}), $query->start_Tr({-align=>'center', bgcolor=>'#9933FF'}), $query->start_th({-align=>'center'}), strong('VOLUNTEER'), $query->start_th({-align=>'center'}), strong('DAY'), $query->start_th({-align=>'center'}), strong('DATE'), $query->start_th({-align=>'center'}), strong('NEEDED'), $query->end_Tr; while (my @val = $sth->fetchrow_array ()) { print $query->start_Tr({-align=>'center', bgcolor=>'#99FF99'}), $query->start_td({-align=>'left'}), $query->checkbox(-name=>"Vol +unteer", -value=>$val[1]), $query->start_td({-align=>'center'}), $val[0], $query->start_td({-align=>'center'}), $val[1], $query->start_td({-align=>'center'}), $val[2], $query->end_Tr; $count++, } print $query->end_table; $query->center( $query->submit(-name=>'rows', -value=>'Submit')), $query->reset, $query->end_form(); print $query->h2({-align=>'center'}, $query->a({href=>'../Schedule.html'}, 'SCHEDULE'), '&nbsp', $query->a({href=>'Roster.pl'}, 'ROSTER'), '&nbsp', $query->a({href=>'../News.html'}, 'NEWS'), '&nbsp', $query->a({href=>'../Pictures.html'}, 'PICTURES'), '&nbsp', $query->a({href=>'../BobSchedule.pl'}, 'BOBS SCHEDULE'), '&nbsp' +, ); print $query->end_html; exit(0)

Replies are listed 'Best First'.
Re: Nothing show up in the browser
by dws (Chancellor) on Jan 25, 2002 at 10:03 UTC
    Why does does the form not show up in the browser? everything before the form prints to screen nothing after.

    I'm surprised you're getting that much. $sth isn't defined, and strict is complaining about it. (You have some other strict problems. perl -cw is your friend.)

    Also, your HTML isn't going to be well-formed. Instead of   $query->start_th({-align=>'center'}), strong('VOLUNTEER'), use   $query->th({-align=>'center'}, strong('VOLUNTEER')), Ditto for where you're trying to use start_td().

      here is the whole script I am getting a syntax error at line 46 near end_Tr; I am just seeing it!
      #!/usr/bin/perl -w #Volunteer.pl - Sign up sheet for Volunteers use strict; use DBI; use CGI; my $query = CGI::new(); my ($dbh, $sth); my $count=1;$sth = $dbh->prepare ("SELECT Day, Date, count(*) FROM Vol +unteer where Volunteer = 'T +BD' and Date > (CURRENT_DATE)-1 group by Date"); $sth->execute () or die "Couldn't execute statement: $DBI::errstr; sto +pped"; print $query->header(); print $query->start_html (-title=>'Volunteer SignUp Form', -link=>'#FFFFFF', -vlink=>'99FF99', -alink=>'black', -style=>{'-src'=>'/CSS/stylesheet.css'}); print $query->h1({-align=>'center'},'1990 MNLIGHTNING SIGNUP SHEET'); print $query->h2({-align=>'center'},'To sign up for a time simply sele +ct the botton indicating if you are the players Mother or Fath er. Only Parents can sign up. Other volunteers must sign up as the pa +rents so we know who is responsible to work those days. Select the dates you are available to work. Submit the information and + verify the choices are correct.'); print $query->start_form('POST', './Signup.pl'), $query->center( $query->radio_group( -name =>'Parent', -value =>['Mother', 'Father'], -default=>'Mother', -linebreak=>'true'), $query->start_table({-align=>'center'}), $query->start_Tr({-align=>'center', bgcolor=>'#9933FF'}), $query->start_th({-align=>'center'}, strong('VOLUNTEER')), $query->start_th({-align=>'center'}, strong('DAY')), $query->start_th({-align=>'center'}, strong('DATE')), $query->start_th({-align=>'center'}, strong('NEEDED')), LINE 49 $query->end_Tr; while (my @val = $sth->fetchrow_array ()) { print $query->start_Tr({-align=>'center', bgcolor=>'#99FF99'}), $query->start_td({-align=>'left'}), $query->checkbox(-name=>"Vol +unteer", -value=>$val[1]), $query->start_td({-align=>'center'}, $val[0]), $query->start_td({-align=>'center'}, $val[1]), $query->start_td({-align=>'center'}, $val[2]), $query->end_Tr; $count++, my $user = $query->remote_user(); } print $query->end_table; $query->center( $query->submit(-name=>'rows', -value=>'Submit')), $query->reset, $query->end_form(); $sth->finish (); $dbh->disconnect (); print $query->h2({-align=>'center'}, $query->a({href=>'../Schedule.html'}, 'SCHEDULE'), '&nbsp', $query->a({href=>'Roster.pl'}, 'ROSTER'), '&nbsp', $query->a({href=>'../News.html'}, 'NEWS'), '&nbsp', $query->a({href=>'../Pictures.html'}, 'PICTURES'), '&nbsp', $query->a({href=>'../BobSchedule.pl'}, 'BOBS SCHEDULE'), '&nbsp' +, ); print $query->end_html; exit(0)
        Ponder on the effect of   $query->center( and try to find where you're closing it.

      dws is right: start_th (or start_td) alone is incorrect.

      OR, if you are going to use start_th and start_td, then use end_th and end_td.

      So, use this:

      $query->th({-align=>'center'}, strong('VOLUNTEER')),

      or this:

      $query->start_th({-align=>'center'}), strong('VOLUNTEER'), $query->end_th({-align=>'center'}),

      instead of this:

      $query->start_th({-align=>'center'}), strong('VOLUNTEER'),

      dmm

      If you GIVE a man a fish you feed him for a day
      But,
      TEACH him to fish and you feed him for a lifetime
Re: Nothing show up in the browser
by grep (Monsignor) on Jan 25, 2002 at 10:19 UTC
    As dws pointed out this will not compile. You are also mixing the OO and the functional interface to CGI.pm (which is bad ju-ju).

    It is always a good idea to either 'command line' a non-working CGI script (Lincoln Stein has done a great job on the CLI for CGI.pm IMHO) or check the error logs of you web server. Either one of these would have pointed you in the right direction.
    $query->start_th({-align=>'center'}), strong('DAY'), ##Should be $query->th({-align=>'center'}), $query->strong('DAY'),




    grep
    grep> cd pub
    grep> more beer
Re: Nothing show up in the browser
by Zaxo (Archbishop) on Jan 25, 2002 at 10:21 UTC

    In addition to dws's and grep's notes, you are not printing the submit and reset buttons, and the end_form method. You probably meant comma for semicolon in the previous print statement.

    Update: Clarified language, added ref to grep's contribution.

    After Compline,
    Zaxo

A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://141434]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-04-24 07:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found