using pg_field_is_null() from Postgres

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dprasad
Forum Newbie
Posts: 6
Joined: Fri Mar 04, 2005 10:31 am

using pg_field_is_null() from Postgres

Post by dprasad »

I'm attempting to test for null values, using postgres and php

Code: Select all

$query22 = "select frequency, count(access) from reg.rur where app=2 and access='local' group by frequency";

     $result22 = pg_query($connection, $query22) or die("0");
     
          if (pg_field_is_null($result22, 0, "frequency") == 1) {
          
                    echo "No users run local copies of this software";
          }
     
               $arr8 = pg_fetch_array($result22, 0, PGSQL_NUM);
                  echo "Frequency of use for ArcMap users: $arr8ї0]. Use a local copy: $arr8ї1]";
This gives me the error: Warning: pg_field_is_null(): Unable to jump to row 0 on PostgreSQL result index 11 in /var/www/html/reg/stats.php on line 139, which is this line:

if (pg_field_is_null($result22, 0, "frequency") == 1) {


thanks for any help!

Dinesh
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'd bet $result22 is invalid... or no rows were returned.
dprasad
Forum Newbie
Posts: 6
Joined: Fri Mar 04, 2005 10:31 am

Post by dprasad »

yes, the access column is null when app is 2 right now, but in the future it may not be. That's why I need to chech, if it is null, a zero needs to be outputted.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

use pg_num_rows() first maybe?
dprasad
Forum Newbie
Posts: 6
Joined: Fri Mar 04, 2005 10:31 am

Post by dprasad »

yes that fixed it

if (pg_num_rows($result22)==0)
{

//if (pg_field_is_null($result22, 0, "access") == 1) {

echo "No users run local copies of this software";
Post Reply