freetds / unixodbs: Field alias in SQL not working

I have a FreeBSD dedicated server with: Apache 2.0, PHP 5.2, unixODBC and FreeTDS Version 8.0 (0.63) configured that can perfectly connect to a MS SQL Server 2005.
(I work with odbc_connect, odbc_result and so on)

Problem description:

A simple SQL statement like this works fine:
$SQL="SELECT TOP 1 IDPRODUCT FROM PRODUCTS WHERE IDPRODUCT > 5000;"

BUT a bit more complex SQL statement like:
$SQL="SELECT PRODUCTNAME AS NAME FROM PRODUCTS WHERE IDPRODUCTS > 5000;"

Gives me an error like this:
Warning: odbc_result() [function.odbc-result]: Field NAME not found in /home/babyshop/public_html/shop.php on line 198

What is wrong?

Do I use the wrong FreeTDS driver or what could this be?

Thx for your help.
projectwebAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roger BaklundCommented:
This is probably not the reason for the error, but I noticed in the first query you have

WHERE IDPRODUCT > 5000

and in the second query:

WHERE IDPRODUCTS > 5000

Remove the S.

Are you sure there is a column named PRODUCTNAME?
0
projectwebAuthor Commented:
:-)

That was just a typo.
Sorry for that. (good try, but i'm afraid it isn't that simple)
0
projectwebAuthor Commented:
I found a workaround myself...

The workaround is

SELECT (PRODUCTNAME AS NTEXT) AS NAME FROM .....

Where the cast funtion is the solution
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.