Skip to Content.
Sympa Menu

freetds - Re: [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 AT lists.ibiblio.org>
  • Subject: Re: [freetds] Php Error
  • Date: Fri, 24 Nov 2006 15:29:24 +1100

Thanks for your suggestions Frediano
I tried your suggestions but unfortunately things came up dry.

Date: Thu, 23 Nov 2006 12:02:32 +0100
From: "ZIGLIO, Frediano, VF-IT" <Frediano.Ziglio AT vodafone.com>
Subject: Re: [freetds] Php Error
To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
Message-ID:
<F7F148C986A2A84F930FEB8C3B169EA00292124D AT OPDMEXO01.omnitel.it>
Content-Type: text/plain; charset="US-ASCII"


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

I imaging you are using a command like

isql TDSLINK sa **********

you should check that apache user has access to /usr/local/etc/odbc.ini
and /usr/local/etc/freetds.conf (difficult if apache is configured in a
chroot). I noted you are root so you cound try with

su apache -c 'cat /usr/local/etc/odbc.ini'
su apache -c 'cat /usr/local/etc/freetds.conf'

My apache install is indeed chrooted.
However the above commands just produced "This account is currently not available"
very odd.


(assuming apache is the user your system use for your web)

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


Mmmm... the error

[unixODBC][Driver Manager]Data source name not found

tell that php is using unixODBC as DM (driver manager). Perhaps you
should use --with-unixODBC.

I tried recompiling php as you meantioned with the --with-unixodbc=/usr/local tag as suggested but i still get the same error message.
Will this require a complete reinstall of apache+php+all relevant modules to get it to work?

Pay attention that FreeTDS and PHP should be linked to the same DM.
a "command -V isql" could help to understand which library you are
using.
I would suggest if possible to have only a DM installed.

I'm trying to access our production MSSQL server to migrate the data over to MYSQL. From what I've read I need freeTDS for this but there seems to be a fair bit of contradictory info out there about this stuff.



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


bye
Frediano Ziglio


Thanks again for your help Frediano
If anyone can suggest an easier way to get this MSSQL link up and running, a different distro maybe (I currently use Fedora5), I'm all ears cos if I can't get it working in the next couple of days I'll have to call it quits.




Archive powered by MHonArc 2.6.24.

Top of Page