I assume you can fix this from the replies to your previous posts. As you code gets more complex, you will find it easier to debug if you organise the code as far as possible into logical self contained blocks e.g. separate the data preparation from the data display. The odd comment line helps too. Like this

use strict; use warnings; use diagnostics; use CGI qw(standard); #use CGI::Carp 'fatalsToBrowser'; use DBI(); use DBD::mysql; # input parameters my $q = CGI->new; my $name = $q->param('name'); # prepare data my $dbh = DBI->connect('dbi:mysql:oncall','webuser','password') or die "Connection Error: $DBI::errstr"; my $sql = 'SELECT name,day,phone FROM users WHERE name = ?'; my $sth = $dbh->prepare($sql); $sth->execute($name); my ($name, $day, $phone) = $sth->fetchrow_array(); $sth->finish(); $dbh->disconnect(); # display data print $q->header; print $q->start_html( -title=>'Users Schedules' ); # use here-doc for html print <<HTML; <h1>Users Schedules</h1> <table border="3" cellpadding="5"> <tr> <th>Name</th> <th>On-Call</th> <th>Phone Number</th> </tr> <tr> <td>$name</td> <td>$day</td> <td>$phone</td> </tr> </table> HTML # if the result is not what you expected # add a debug line to show what the # database is being asked to do print "<hr/><tt>SQL=[$sql] : ?=[$name]</tt>"; print $q->end_html;
poj

In reply to Re: Returning values from mysql with cgi by poj
in thread Returning values from mysql with cgi by Chaotic Jarod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.