473,378 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

PHP+ODBC+FREETDS: select [field] AS [name] does not work!

1
Hi guys,

I have a unix server which has PHP 5.2.13 installed, and it has access to two SQL servers (one is running MSSQL SERVER 2000 and the other MSSQL 2005).

It uses FreeTDS - details:
Version: freetds v0.82
freetds.conf directory: /usr/local/etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 8.0
iODBC: no
unixodbc: yes

And I'm using unixODBC-2.3.1

The MSSQL 2000 server is fine, I can run all SQL statements and use mssql_num_rows and mssql_fetch_assoc much as you would with MySQL.

However, the MSSQL 2005 server won't work with mssql_num_rows or mssql_fetch_assoc - you have to use odbc_fetch_row.

That's not really an issue, I assum it's just due to the different server installs.

However, I have a huge issue with the MSSQL 2005 server: I cannot select a field AS another name!

For example:

SELECT
[EnquiryID] AS "The_Key"
FROM [db].[dbo].[table]

Works fine in my admin application (ie: NOT PHP), but if I run the same in my PHP environment, I get:

stdClass Object
(
[PK_EnquiryID] => 1
)

You can see it should be [The_Key] => 1

Has anyone any idea how we can get round this? I'm tearing my hair out!

Cheers

Neil
May 15 '12 #1
0 1298

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Consuelo Guenther | last post by:
Hello, I have an asp page that has a function that connects to an Access database. I am using Javascript. Is there any way to reference the field name in the database through a variable in a sql...
3
by: Louis | last post by:
Is there a switch or a setting in Access so that a group by query doesn't return a field name SumOf(original field name)? Especially when you chain multiple queries together you'd get...
2
by: Ray | last post by:
I tried to change the field name in a query using "New Name: ". It did not work at all and just display the caption of the Field Name. Is it possible to change the field name or use a new caption...
11
by: Eych | last post by:
I get a VB error when I try to update a table whose field I change with the following statement: dcUpdate.Dataset.Tables(0).Rows(0)("User Name") = Me.textbox1.Text if I change the field name...
5
by: HS1 | last post by:
Hello I have a datagrid to show data for a database table using "seclect * from tablename" The datagrid works OK. However, I want to change the name of the fields in the database to other...
11
by: pmarisole | last post by:
I am trying to use the vbscript "split" function on a multi-select field. I am trying to do a mass update of several records at a time. I am getting an error and I'm not sure what to do. Here is...
3
by: Daron | last post by:
Is it possible to use a parameter as the field name, not just a criteria? Snippet of my SQL: SELECT Eval("!!.(0)") AS TestField, AS from qry_main The parameter will hold the name of the...
5
by: nephish | last post by:
hey there, can anyone tell me if this is legal php/mysql ? i am trying to write a simple function to get a single stat from a single table. eg.. $field = 'phone_number'; $customer = 'fred';
12
klarae99
by: klarae99 | last post by:
Hi everyone, I am new to Access 2003 (though my time on scripts has helped alot) and am creating an inventory database. In my original table design I had a field tblTrans.Date which I was advised to...
3
by: DD77 | last post by:
i need to query an xml field, but the node name i am looking for is not constant and needs to be taken out of join result. i was trying to do something like this but it does not work: select...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.