Hi all,
 
I'm getting an error when trying to do an INSERT statement to a MySQL database. 
There's something I'm not understanding here. Can anyone point me in the right 
direction? I also tried a "do" method, but got the same error. I know the 
"param" function is loading the values from the form, because I've used a 
"print" statement to check the variables.
 
TIA
Ron
 
---------------------snip---------------------------
Software error:
Can't call method "execute" on an undefined value at 
C:/www/cgi-bin/load_company_products.cgi line 21.
For help, please send mail to the webmaster ([EMAIL PROTECTED]), giving this 
error message and the time and date of the error.
---------------------snip---------------------------
#!/www/perl/bin/perl -wT
use strict;
use DBI;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
my $sku = param('sku');
my $partNum = param('partNum');
my $name = param('name');
my $descr = param('descr');
my $stockNum = param('stockNum');
my $qty = param('qty');
my $img = param('img');
my $vendNum = param('vendNum');
my $price = param('price');
my $dbh = DBI->connect("DBI:mysql:company", "username", "password") or die 
"Error: $DBI::errstr\n";
my $sql = "INSERT INTO products VALUES ('$sku', '$partNum', '$name', '$descr', 
'$stockNum', '$qty', '$img', 'vendNum', '$price')";
my $sth = $dbh->prepare($sql);
my $sth->execute; <=============line 21
$dbh->disconnect;

#my $sth->do("INSERT INTO products VALUES ('$sku', '$partNum', '$name', 
'$descr', '$stockNum', '$qty', '$img', 'vendNum', '$price')");
------------snip---------------

Reply via email to