Received: from mail.sysnet.net.tw (mail.sysnet.net.tw [210.67.33.9]) by hub.org (8.9.2/8.9.1) with ESMTP id AAA37642 for ; Tue, 9 Feb 1999 00:46:48 -0500 (EST) (envelope-from jwlo@ms11.hinet.net) Received: from ms11.hinet.net (p210-67-40-116.ts.sysnet.net.tw [210.67.40.116]) by mail.sysnet.net.tw (8.8.8/8.8.8) with ESMTP id NAA18620; Tue, 9 Feb 1999 13:45:44 +0800 (CST) Sender: kevin@mail.sysnet.net.tw Message-ID: <36BFCB69.6E5CD364@ms11.hinet.net> Date: Tue, 09 Feb 1999 13:45:14 +0800 From: Kevin Lo X-Mailer: Mozilla 4.5 [en] (X11; I; FreeBSD 2.2.8-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: jeff , pgsql-interfaces@postgreSQL.org Subject: Re: [INTERFACES] ack... problems with Pg, please advise. References: <36BF851F.4CA449BD@hctc.com> Content-Type: text/plain; charset=big5 Content-Transfer-Encoding: 7bit Jeff wrote: > hello, i just installed postgreSQL and it works great, i imported my db > and it works great with the psql interface, and i even can access it > from the shell with a perl script. but when i cut and paste the code > into a cgi, it returns nulls (albiet the appropriate number of nulls). > here is my code, what am i doing wrong? thanks. > > > > unless ($a) {$a="Metallica";} > > $conn = Pg::connectdb("dbname=tempest"); > (PGRES_CONNECTION_OK eq $conn->status ) > and print "Pg::connectdb ........... ok
" > or die "Pg::connectdb ........... not ok: ", $conn->errorMessage; > > # this part works, as the "ok" message is shown on the page... > > $result = $conn->exec("SELECT title from cds where artist='$a'"); From the DBI module documentation: Note that prepare should never execute a statement, so this should be $rc = $dbh->do("SELECT title from cds where artist='$a'") or die $DBI::errstr; > while ( @row=$result->fetchrow ) { > print "@row"; > print "
\n"; > } > > > it returns the correct number of
s, but prints nothing, @rows > appear to be null. any ideas? BTW, would you check the log file of httpd server to see if any fails? Regards, Kevin.