Ooops!! Thanks!! Jenda Krynicky <[EMAIL PROTECTED]> wrote:From: jason corbett > I am trying to learn about binding variables. i am writing a simple > script that with select a row of records and print them to screen. I > am getting the error Can't call method "bind_param" on an undefined > value at porqout.pl line 29. > > Here is the code below. > > #!/usr/bin/perl -w > use strict; > use DBI; > > my $ctn_number='67846270'; > > $dbh->prepare("select * from ctn_inv where ctn = ?"); > $sth->bind_param( 1,$ctn_number);
Don't tell me strict doesn't complain! Where do you declare $sth and where do you assign to it? It's the prepare() method that creates the statement object you should assign to $sth: my $sth = $dbh->prepare("select * from ctn_inv where ctn = ?"); $sth->bind_param( 1,$ctn_number); ... > $sth->execute(); > > $dbh->prepare("select * from ctn_inv where ctn = ?"); > $sth->bind_param( 1,$ctn_number); > > $sth->execute(); > > while( my @record= $sth->fetchrow_array()) > > my $record_list = join ',', @record; > print "\n$record_list"; > > my $sth->finish; What do you expect this to mean? The "my" definitely does not belong here, you do not want to create a brand new empty $sth and call a method on it. Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]