views:

51

answers:

2

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.

+1  A: 
  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.

sanmai
Not working.Folowed the steps you said,but not working!
shrikant.soni
A: 

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)

jjclarkson
Hi -These variables might be needed. But the immediate problem is "Call to undefined function odbc_connect()".Sanmai is correct - the OP first needs to install php5-mssql and/or php5-odbc.
@shrikant-soni stated that he did install those in his comment, I'm assuming he tried that and it did not work, perhaps changing his error message???
jjclarkson
Perhaps he did not restart Apache after the installation.
sanmai