pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dan Langille <dan@langille.org>
To: Jim Martinez <jjm@bigbigorg.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: false No rows returned error
Date: Sat, 23 Mar 2002 12:35:14 -0500
Message-ID: <20020323173453.D386E3F30@bast.unixathome.org> (raw)
In-Reply-To: <Pine.LNX.4.33.0203230955120.7406-100000@unagi.e-techservices.com>

On 23 Mar 2002 at 11:04, Jim Martinez wrote:

> <?
> $conn=pg_connect("user=scott");
> 
> // make sure I'mconnecting to the correc db
> echo "<b>database name:". pg_dbname($conn)."</b></hr>\n";
> 
> if (!$conn){
>         exit(" connection failed: " . __FILE__ . __LINE__ . "error: " . 
>         pg_errormessage($conn) );
> }
> 
> $sql = "select pin, last_section_completed, comment from demographics";
> 
> $res = pg_exec($conn, $sql) || exit ("query failed: ".__FILE__ . __LINE__ 
> ."<br> sql is $sql" );

Change the above to this, just to be sure:

res = pg_exec($conn, $sql);
if (!$result) {
	echo "query failed: ".__FILE__ . __LINE__ ."<br> sql is $sql" );
	exit;
}

> if (!$res){ exit ("post query check failed");}

BTW: the above if isn't necessary given the above.

> 
> // 
> // script dies here (line 36), falling to the exit clause.
> // A warning is printed also : 
> // Warning: Supplied argument is not a valid 
> // PostgreSQL result resource 
> // in /home/www/test/php_debug.php on line 36

Listen to this error.

> $rows = pg_numrows($res) || exit ("No rows returned ".__FILE__ ." line:". 
> __LINE__ . "<br> sql is $sql" ); // line 36

-- 
Dan Langille
The FreeBSD Diary - http://freebsddiary.org/ - practical examples




view thread (5+ messages)  latest in thread

Message-ID: <20020323173453.D386E3F30@bast.unixathome.org>
Permalink:  ../20020323173453.D386E3F30@bast.unixathome.org/
Also on:    postgresql.org/message-id/20020323173453.D386E3F30@bast.unixathome.org

 · 

reply

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-sql@postgresql.org
  Cc: dan@langille.org, jjm@bigbigorg.org
  Subject: Re: false No rows returned error
  In-Reply-To: <20020323173453.D386E3F30@bast.unixathome.org>

* 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