Re: Question about this simple CGI
by toolic (Bishop) on Jul 17, 2013 at 19:55 UTC
|
#ffffff is not correct syntax. Maybe change:
$q->start_html( -title => "Add user", -bgcolor => #ffffff);
to:
$q->start_html( -title => "Add user", -bgcolor => 0xffffff);
| [reply] [d/l] [select] |
|
That fixed that, not it's telling me that $day and $number are both unitialized, any clue why?
| [reply] |
|
my $name = $q->param('name') || 'noname';
my $day = $q->param('day') || 'noday';
my $number = $q->param('number') || 'nonumber';
The elements after the print line should be comma separated and you shouldn't be printing after the end_html
print $q->header,
$q->start_html( -title => "Add user", -bgcolor => "#ffffff"),
$q->p("Data submitted"),
$q->tt("$name<br/>$day<br/>$number"),
$q->end_html;
And you may wish to add this while developing to see any errors in the browser.
use CGI::Carp 'fatalsToBrowser';
poj | [reply] [d/l] [select] |
|
| [reply] |
Re: Question about this simple CGI
by Old_Gray_Bear (Bishop) on Jul 17, 2013 at 19:56 UTC
|
| [reply] [d/l] [select] |
Re: Question about this simple CGI
by MidLifeXis (Monsignor) on Jul 17, 2013 at 20:32 UTC
|
You are also not printing the start_html, p, or end_html data. s/;/,/.
| [reply] [d/l] [select] |
Re: Question about this simple CGI
by Perlbotics (Archbishop) on Jul 17, 2013 at 20:41 UTC
|
Other monks already gave you good advice (quote, initialise, print).
Seeing, use DBI;, use DBD::mysql;, and the early stage of an Add user
CGI script, I feel obliged to drop the obligatory link ;-)
A term project should provide a good opportunity to train these skills right from the start.
Looking into Dancer or Mojolicious might also be worthwhile?
| [reply] [d/l] [select] |
Re: Question about this simple CGI
by CountZero (Bishop) on Jul 18, 2013 at 13:54 UTC
|
| [reply] [d/l] [select] |
|
I use parens in use calls to explicitly show that nothing is getting imported from the module.
| [reply] |
|
~>ack \@EXPORT DBI.pm
@EXPORT = (); # we export nothing by default
@EXPORT_OK = qw(%DBI %DBI_methods hash); # also populated by export_ok
+_tags:
Update: DERP, didn't see the whole thread. CountZero is asking a good question. The answer to which is... left as an exercise for the reader you. | [reply] [d/l] |
Re: Question about this simple CGI
by kcott (Archbishop) on Jul 20, 2013 at 08:54 UTC
|
G'day Chaotic Jarod,
"... it says there is a syntax error on the end_html line,"
You appear to have resolved the issue; however, you may still be wondering why the error was reported as being on the syntactically correct "$q->end_html;" line.
Take a look at perldiag and search for:
This will explain why the error is often reported after the point where the actual error occurred.
In this case, Perl ignores the comment you wrote (i.e. '#ffffff);') — as it obviously has no idea you didn't mean that to be a comment — and continues parsing your code until it reaches "$q->end_html;" where it gives up having found no valid end to '$q->start_html(...'.
While you're learning Perl, you might consider using the diagnostics pragma which will provide verbose output regarding problems you encounter.
Be aware that this is a debugging aid and should not be left in production code (and that would include what you submit for your project).
Finally, if you're unable to resolve the error yourself, feel free to ask but do include the full error message when you post your problem.
| [reply] [d/l] [select] |