Hello Monks,

I have a database that contains shipment information. Right now, I want to show two fields: customer_id and tracking_number.

I have an HTML form where the customer will enter their customer id number. The form element name is custid.

I'm trying to write a script that will take the customer id number which was entered into the form and passed to the database table to extract the information only for that customer.

When I run the script, I'm receiving a compilation error and I'm not sure what the problem could be.

Below is the code for the script.

Any help is greatly appreciated.

Thank you in advance.
#!/usr/bin/perl -Tw use CGI qw(:standard); use strict; use lib qw(/export/ext2/www/bartellmachinery/library); use CGI::Carp qw(fatalsToBrowser); use CGI qw(:standard escape escapeHTML); use WebDB; my $cust_ref; #reference to customer #@PAGE_START my $dbh = WebDB::connect (); my $page = h3 ({-align=>"center"}, ("Order Tracking System")); #@PAGE_START # get the form parameters $cust_ref->{custid} = param ("custid"); my $choice = lc (param ("choice")); if ($choice eq "submit") # customer submitted ID number { $page .= get_customer ($dbh, $cust_ref); } else { $page .= p (escapeHTML ("Logic error, unknown choice: $choice")); } print header (), start_html (-title => "Order Tracking System", -bgcol +or => "white"); sub get_customer { my ($dbh, $cust_ref) = @_; my ($page); my $sth = $dbh->prepare ("SELECT * FROM Shipments WHERE customer_id = +?"); $sth->execute ($cust_ref->{custid}); my @rows; while (my $order_ref = $sth->fetchrow_hashref ()) { push @rows, Tr ({-style=>"font-family: verdana; font-size: 10pt;"}, td ({-colspan => "2"}, ""), td ({-colspan => "3", -align=>"right", -style=>"font-weight: +700;"}, "Customer ID:"), td (escapeHTML ($order_ref->{customer_id)), ); Tr ({-style=>"font-family: verdana; font-size: 10pt;"}, td ({-colspan => "2"}, ""), td ({-colspan => "3", -align=>"right", -style=>"font-weight: +700;"}, "Tracking Number:"), td (escapeHTML ($order_ref->{tracking_number)), ); $page .= table ({-border => 1, -align => "center"}, return ($page); $sth->finish(); }

In reply to Compilation Error by b310

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.