php_num_fields incorrect

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
PhpDog
Forum Commoner
Posts: 58
Joined: Mon Jan 14, 2008 10:23 am

php_num_fields incorrect

Post 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:
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: php_num_fields incorrect

Post by Christopher »

If you are returning data in an associative array then probably two fields have the same name.
(#10850)
PhpDog
Forum Commoner
Posts: 58
Joined: Mon Jan 14, 2008 10:23 am

Re: php_num_fields incorrect

Post by PhpDog »

The field names are unique. So, unfortunately, that's not it.
Post Reply