Hello Monks,
Happy Easter!
I'm trying to insert some data from a form into a table and I'm receiving the following error message:
Can't call method "do" on an undefined value
I'm having a tough time trying to figure this out.
Can someone lend me a hand?
Here's the code...
#! /usr/local/bin/perl -w
use strict;
use lib qw(/usr163/home/w/s/wstrader/public_html/library);
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard escape escapeHTML);
use WebDB;
my $dbh = WebDB::connect ();
my $name = param("name");
my $coname = param("coname");
my $phone = param("phone");
my $email = param("email");
my $address = param("address");
my $city = param("city");
my $state = param("state");
my $zip = param("zip");
my $country = param("country");
my $page;
my $choice = lc (param ("choice"));
if ($choice eq "submit") # information submitted via form
{
store_items ($dbh);
}
else
{
$page .= p (escapeHTML ("Logic error, unknown choice: $choice"));
}
sub store_items
{
my $dbh;
$dbh->do ("INSERT INTO contact_info
(contact_date,contact_name,company,telephone,email,addre
+ss,city,state,zip_code,country)
VALUES (CURRENT_DATE,?,?,?,?,?,?,?,?,?)",
undef,
$name,
$coname,
$phone,
$email,
$address,
$city,
$state,
$zip,
$country);
$dbh->disconnect();
}
Thank you for the help.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.