List:General Discussion« Previous MessageNext Message »
From:Vivek Khera Date:April 28 1999 9:54pm
Subject:Re: Perl DBI, for archiving
View as plain text  
>>>>> "CK" == Charles Kirby <kirbych@stripped> writes:

CK> my $dbh = DBI->connect("DBI:mysql:$dbname", $dbuser, $dbpasswd)
CK>     or die "can't connect: $DBI::errstr\n";

CK> my $query = <<"EOS";
CK> SELECT sid
CK> FROM slips
CK> WHERE sid='1' 
CK> EOS
CK> my $sth = $dbh->prepare($query) or die "can't prepare $query: ",
CK> $dbh->errstr, "
CK> \n";  
CK> $sth->execute($sid); 

If you want to pass a parameter to execute and have it that value
filled into your SQL, then you need to use "placeholders" in your
$query string.  A place holder is nothing more than a ? symbol.  I'm
assuming to get the desired effect, you want to change

 sid='1'

to 

 sid=?

and then re-try your program.

CK> while(@row = $sth->fetchrow_array) {
CK>      print "@row\n";      
CK>      }


								v.

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.                Khera Communications, Inc.
Internet: khera@stripped       Rockville, MD       +1-301-545-6996
PGP & MIME spoken here            http://www.kciLink.com/home/khera/
Thread
Perl DBI, for archivingCharles Kirby29 Apr
  • Re: Perl DBI, for archivingVivek Khera29 Apr
    • Re: Perl DBI, for archivingCharles Kirby29 Apr
      • Re: Perl DBI, for archivingPaul DuBois29 Apr
      • Re: Perl DBI, for archivingVivek Khera29 Apr
        • Re: Perl DBI, for archivingCharles Kirby29 Apr
          • Re: Perl DBI, for archivingPaul DuBois29 Apr
            • Re: Perl DBI, for archivingCharles Kirby29 Apr