Skip to Content.
Sympa Menu

freetds - Re: [freetds] Php Error

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "ZIGLIO, Frediano, VF-IT" <Frediano.Ziglio AT vodafone.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Php Error
  • Date: Thu, 23 Nov 2006 12:02:32 +0100

>
> 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'

(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.
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 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





Archive powered by MHonArc 2.6.24.

Top of Page