Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

post data from db on website

by baperl (Sexton)
on Oct 10, 2011 at 15:48 UTC ( #930675=perlquestion: print w/ replies, xml ) Need Help??
baperl has asked for the wisdom of the Perl Monks concerning the following question:

hi, I am trying to extract data from the sql db to publish it on a website. It prints the header fine, but not the print response section.
sub print_response { unless ($query->param) { print "<b>No data has been submitted</b>"; return; } $sql = "SELECT col1, col2 FROM test ORDER BY col2 desc;"; $sth=$dbh->prepare($sql) or die $dbh->errstr; $sth->execute; print "</td><td>"; print "<table border>"; print "<tr>"; print "<th>col1</th>"; print "<th>col2</th>"; print "</tr>"; while (my $hash_ref = $sth->fetchrow_hashref) { $the_st = $hash_ref->{'col1'}; $the_mc = $hash_ref->{'col2'}; print "<tr><td>$the_st</td><td align=\"right\">$the_mc</td></tr> +"; } print "</table></td></tr></table>"; $sth->finish; }
Can you please let me know where my error is. thanks!

Comment on post data from db on website
Download Code
Re: post data from db on website
by moritz (Cardinal) on Oct 10, 2011 at 16:11 UTC

    Do you actually call that sub? Where? I don't see the call in your code, that would be an important part to show.

    Did you submit POST parameters?

    Did you view the HTML source of the response? Is the body header there?

      thanks for the questions....yes....I realized I had a typo - missing a double quote :-(
        If possible, use strict; and use warnings; - this should help you avoid many typos.
        Don't use '#ff0000':
        use Acme::AutoColor; my $redcolor = RED();
        All colors subject to change without notice.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2014-09-18 04:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (108 votes), past polls