Re: false No rows returned error - Mailing list pgsql-sql

From Dan Langille
Subject Re: false No rows returned error
Date
Msg-id 20020323173453.D386E3F30@bast.unixathome.org
Whole thread Raw
In response to false No rows returned error  (Jim Martinez <jjm@bigbigorg.org>)
Responses Re: false No rows returned error  ("Dan Langille" <dan@langille.org>)
Re: false No rows returned error  (Jim Martinez <jjm@bigbigorg.org>)
List pgsql-sql
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



pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: false No rows returned error
Next
From: "Dan Langille"
Date:
Subject: Re: false No rows returned error