Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unixODBC Freetds PHP Problem

I am using Debian. I have unixODBC installed as well as FreeTDS. I am using PHP

I have read several How-Tos and am stuck on a problem.

I tested FreeTDS by using tsql and it works.

I tested unixODBC by using isql and it works.

When I created a script in PHP and tried to access a database I get the following errors.

Fatal error: Call to undefined function odbc_connect()

I have found multiple php.ini files. Which is the one that Apache2 uses? Is there something in there that needs to be set.

Is there some setting that I missed seting that was not in the How-Tos?

All help is greatly appreciated.

like image 255
Shrikant Soni Avatar asked Aug 16 '10 06:08

Shrikant Soni


2 Answers

You may need to provide environment variables to point to the location of your ODBC configuration files:

<?php
putenv("FREETDSCONF=/etc/freetds/freetds.conf");
putenv("ODBCSYSINI=/etc/odbcinst.ini");
putenv("ODBCINI=/etc/odbc.ini");

This works for me to connect to several ODBC databases. (Your config files might be somewhere else)

like image 181
jjclarkson Avatar answered Nov 03 '22 23:11

jjclarkson


  1. You need to install php5-mssql and/or php5-odbc. I'd recommend you to install both just for sure.

  2. Files from /etc/php5/conf.d/ and /etc/php5/apache2/php.ini used to store PHP configuration options in Debian.

like image 24
sanmai Avatar answered Nov 03 '22 23:11

sanmai