Brady A. Johnson wrote:
> Greetings,
> 
> I am having trouble with the PostgreSQL pg_FieldNum() funciton.  When I 
> execute the following:
> 
>   $DB = pg_Connect ( "dbname=lists" );
>   $Recs = pg_Exec ( $DB, "SELECT 123 AS \"ABC\"" );
> 
>   $FieldName = pg_FieldName ( $Recs, 0 );
>   print ( "<p>FieldName: $FieldName</p>" );
> 
>   $FieldNum = pg_FieldNum ( $Recs, $FieldName );
>   print ( "<p>FieldNum: $FieldNum</p>" );
> 
> I get:
> 
>   FieldName: ABC
>   FieldNum: -1
> 
> It seems that no matter what I pass to pg_FieldNum(), I get -1 (error) in 
> return.
> 
> Anyone spot what I am doing wrong?
> 
> I am using PostgreSQL 7.0.2 and PHP 4.0.3 on RH Linux 7.0.
> 

I think you need to upgrade your PHP versoin.
I'm using 4.2.0-dev/PostgreSQL 7.1.3. I do not
have problem at all with following script.

<?php

$db = pg_connect('user=yohgaki');

$res = pg_query("SELECT * FROM pg_class");
$fn  = pg_field_num($res, 'reltype');

echo 'Field num is '.$fn."\n"; // $fn is 1

$res = pg_query("SELECT 1 AS one");
$fn  = pg_field_num($res, 'one');

echo 'Field num is '.$fn."\n"; // $fn is 0

?>

-- 
Yasuo Ohgaki


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to