From: Charles Kirby Date: April 29 1999 7:05pm Subject: Re: Perl DBI, for archiving List-Archive: http://lists.mysql.com/mysql/2644 Message-Id: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Aha, that was it! Like you said, I put "$sth->execute()" , so there are no arguments in the statement, and this time I got the expected output (a series of lines of items, each one being a different sid value)! At least I'm making some progress, even if I'm not 100% sure what the exectute/prepare and quote stuff is doing, thanks, ck On Thu, 29 Apr 1999, Paul DuBois wrote: > At 7:55 AM -0500 4/29/99, Charles Kirby wrote: > >Paul DuBois wrote: > >I don't really understand what you're trying to accomplish, exactly... > > > >On Thu, 29 Apr 1999, Vivek Khera wrote: > > > >> Wildcard substitution is a DBI thing, not a mysql command line thing. > >> > >> try "select sid from slips where sid=3;" in mysql command prompt. > > > >By "mysql command line", I mean when I log in (/usr/local/mysql/bin/mysql) > >and select a database. At the mysql> prompt, the wildcard "%" certainly > >does work (with no relevance to DBI), and your suggestion above works, > >also (sid #3 exists). However, it seems when I'm successful in finding a > >match, that's when this thing fails, and I get > >"execute called with 1 bind variables when 0 are needed at ./d.cgi line... > >"Database handle destroyed without explicit disconnect." > > > >What I'm trying to do is this: > > > >my $query = <<"EOS"; > >SELECT sid FROM slips WHERE sid=3 > >EOS > >my $sth = $dbh->prepare($query) or die ... > >$sth->execute($sid); > >while(@row = $sth->fetchrow_array) { > > print "@row\n"; > > } > > Why are you passing $sid to $sth->execute()? This is where your error > message comes from. DBI thinks it's supposed to insert the value of > $sid in the query where it finds ? in the query string, but you don't > have ? in the query string. > > You either need to say "WHERE sid=?" in your query string rather > than "WHERE sid=3", or else invoke execute as $sth->execute() with > no parameters. I'm not sure which, because your query doesn't > make any sense to me. Why select sid when you specify the value of > sid in the WHERE clause? You already know what it will be. > > -- > Paul DuBois, paul@stripped > Northern League Chronicles: http://www.snake.net/nl/ >