Page 1 of 1

php_num_fields incorrect

Posted: Thu Feb 14, 2008 7:27 am
by PhpDog
Here's a strange one:

I use s SELECT query with MS SQL Server 2005 thus :-

SELECT TOP 1

t1.first_name,
t1.last_name,
t1.age,
status,
... more t1.fields ..
t2.description,
t2.category

FROM table1 t1, table2 t2

and then get the number of fields returned with

$fields = mssql_num_fields($result);

In my actual work only 22 fields are returned, whereas it should actually be 24 (two fields from table2 and 22 fields from table1.

If I cut and past my SELECT query into MS SQL Server Management Studio it returns the 24 fields expected.

Anyone know why please? It's driving me nuts :banghead:

Re: php_num_fields incorrect

Posted: Thu Feb 14, 2008 8:00 am
by Christopher
If you are returning data in an associative array then probably two fields have the same name.

Re: php_num_fields incorrect

Posted: Thu Feb 14, 2008 9:07 am
by PhpDog
The field names are unique. So, unfortunately, that's not it.