Skip to Content.
Sympa Menu

freetds - [freetds] Php Error

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Michael Dobeson" <michael.dobeson AT labmark.com.au>
  • To: "FreeTDS" <freetds AT lists.ibiblio.org>
  • Subject: [freetds] Php Error
  • Date: Thu, 23 Nov 2006 16:17:32 +1100

Morning Peoples

I've spent the last few days working through setting up FreeTDS and seem to
have fallen at the last hurdle.

I can access the database using the isql command successfuly, however trying
to get a php script on a website fails with the following error:

[Thu Nov 23 15:36:57 2006] [error] [client 127.0.0.1] PHP Warning:
odbc_connect() [<a href='function.odbc-connect'>function.odbc-connect</a>]:
SQL error: [unixODBC][Driver Manager]Data source name not found, and no
default driver specified, SQL state IM002 in SQLConnect in
/var/www/html/index.php on line 74


Here is the php script I'm using:

<?php
// connect to DSN MSSQL with a user and password
$connect = odbc_connect("TDSLINK", "sa", "**********") or die
("couldn't connect");
odbc_exec($connect, "use PLIMS_TEST");
$result = odbc_exec($connect, "SELECT METHOD, SAMPLE " .
"FROM ANALYSIS_IMPORT");
while(odbc_fetch_row($result)){
print(odbc_result($result, "METHOD") .
' ' . odbc_result($result, "SAMPLE") . "<br>\n");
}
odbc_free_result($result);
odbc_close($connect);
?>


This produces "couldn't connect" everytime.
Below are my various config file incase that helps.

[root@localhost httpd]# cat /usr/local/etc/odbc.ini
[ODBS Data Sources]
TDSLINK = Microsoft SQL Server

[TDSLINK]
Description = TDS MSSQL
Driver = /usr/local/lib/libtdsodbc.so
Servername = TDS
Database = PLIMS_TEST
Trace = No
Port = 1433
[Default]
Driver = /usr/local/lib/libtdsodbc.so


[root@localhost httpd]# cat /usr/local/etc/freetds.conf
[TDS]
host = FS02.**.com.au
port = 1433
tds version = 8.0


I understand that php needs to told how to find the odbc connection, but the
only info i could find was the run the following commands as per the Freetds
User guide.

$ cd php
$ ./configure --with-iodbc=/usr/local
$ make
$ su root
Password:
$ make install


I down loaded php 4.4.4 and ran the above config and makes. But it made no
difference.

any help would be great. management is really against me using Linux in the
first place, and if i can't get this working in the next day or so it will
be the final nail in the coffin.


Thanks
Michael






Archive powered by MHonArc 2.6.24.

Top of Page