[freetds] Php Error
michael.dobeson at labmark.com.au
Thu Nov 23 23:29:24 EST 2006
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>
> <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
> (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
>> 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:
>> // 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");
>> print(odbc_result($result, "METHOD") .
>> ' ' . odbc_result($result, "SAMPLE") . "<br>\n");
>> This produces "couldn't connect" everytime.
>> Below are my various config file incase that helps.
>> [root at localhost httpd]# cat /usr/local/etc/odbc.ini
>> [ODBS Data Sources]
>> TDSLINK = Microsoft SQL Server
>> Description = TDS MSSQL
>> Driver = /usr/local/lib/libtdsodbc.so
>> Servername = TDS
>> Database = PLIMS_TEST
>> Trace = No
>> Port = 1433
>> Driver = /usr/local/lib/libtdsodbc.so
>> [root at localhost httpd]# cat /usr/local/etc/freetds.conf
>> 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
>> $ 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
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
> 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
>> 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.
> 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.
More information about the FreeTDS