From: Kevin Lo <jwlo@ms11.hinet.net>
To: jeff <jeffers@hctc.com>
To: pgsql-interfaces@postgreSQL.org
Subject: Re: [INTERFACES] ack... problems with Pg, please advise.
Date: Tue, 09 Feb 1999 13:45:14 +0800
Message-ID: <36BFCB69.6E5CD364@ms11.hinet.net> (raw)
References: <36BF851F.4CA449BD@hctc.com>
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.
>
> <begin code snippet>
>
> unless ($a) {$a="Metallica";}
>
> $conn = Pg::connectdb("dbname=tempest");
> (PGRES_CONNECTION_OK eq $conn->status )
> and print "Pg::connectdb ........... ok<br>"
> 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 "<br>\n";
> }
> <end code snippet>
>
> it returns the correct number of <br>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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: jwlo@ms11.hinet.net, jeffers@hctc.com
Subject: Re: [INTERFACES] ack... problems with Pg, please advise.
In-Reply-To: <36BFCB69.6E5CD364@ms11.hinet.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox