I am currently having issues getting odbc_connect to work on my CentOS server. I have installed the Easysoft ODBC-SQL-Server driver with the aim to connect to a Microsoft SQL Server 2012.
I am getting the error:
PHP Fatal error: Call to undefined function odbc_connect()
When using odbc_connect()
.
> ls /etc/php.d
> curl.ini json.ini pdo.ini pdo_sqlite.ini sqlite3.ini
> fileinfo.ini odbc.ini pdo_odbc.ini phar.ini zip.ini
> cat pdo_odbc.ini ;
> Enable pdo_odbc
> extension module extension=pdo_odbc.so
I have installed the package php-odbc and restarted my server, is there anything else I need to do to make sure PHP has access to the odbc methods?
UPDATES
php --ini
points to
/usr/local/lib/php.ini
Which doesnt have any mention of ODBC.
Running the command"
php -i |grep ini
gives:
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
user_ini.cache_ttl => 300 => 300
user_ini.filename => .user.ini => .user.ini
init_command_executed_count => 0
init_command_failed_count => 0
com_init_db => 0
Classes => AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, CallbackFilterIterator, DirectoryIterator, DomainException, EmptyIterator, FilesystemIterator, FilterIterator, GlobIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, MultipleIterator, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveCallbackFilterIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RecursiveTreeIterator, RegexIterator, RuntimeException, SplDoublyLinkedList, SplFileInfo, SplFileObject, SplFixedArray, SplHeap, SplMinHeap, SplMaxHeap, SplObjectStorage, SplPriorityQueue, SplQueue, SplStack, SplTempFileObject, UnderflowException, UnexpectedValueException
open sourced by => Epinions.com
The command
nm /usr/local/bin/php |grep odbc
gives no output.
Make sure that you are working on the right php config.
run the following command to know the right odbc ini file
php --ini
Double check that there's a ini file in /etc/php.d
. It should look something like 20-odbc.ini
and should point to the .so
file
Make sure the php.d directory is the correct one. If you run this
php -i|grep php.d
Does everything point to /etc/php.d
or is there another php
configuration location. On Centos 6 it's common to see versions of PHP that have been installed to replace the one that comes bundled with it because it's obsolete, the new version could be installed anywhere, quite often in /opt/rh/php[version num here]
. Any additional packages installed using Yum likely won't reference the new PHP if that's what's being referenced on command line.
If thats not showing any output what does this show...
php -i |grep ini
This should give you the location of the php.ini file it's using. If it's not in
/etc/php.ini
Someone has locally installed php. You should also see a line like
Scan this dir for additional .ini files => /usr/local/etc/php/5.5/conf.d
This will show you were it's looking for things like odbc. Find the PHP binary ie
which php
then run this on it
nm /usr/local/bin/php |grep odbc
If this gives you a lot of symbols with odbc in the name then php was compiled with odbc support, if it doesn't then odbc is not supported by that PHP binary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With