Php odbc connect undefined function

Call to undefined function odbc_connect() php 7

I’m testing out php 7 and have come across this error: Fatal error: Uncaught Error: Call to undefined function odbc_connect() From the doc page: http://php.net/manual/en/function.odbc-connect.php php 7 is not listed as supported. Does anyone have a way around this or know when it will be supported? Thanks@

I’m voting to close this question as off-topic because OP is looking for nonexistent magical solution.

Wow it’s out for 2 weeks and it’s a non existent magical solution? Do you have information where they plan on not supporting it? I can wait a little while.

7 Answers 7

There is written in doc: ODBC support doesn’t need any extension dll. It is true in PHP 5.x, I had to remove «extension=php_odbc.dll» from ini file.
But in PHP 7 I had to put it back.

I found the file «ext/php_odbc.dll» in the new PHP 7 directory again. It works for me :).

The DOC page does list PHP 7, so just install php-odbc and you should be good to go. Currently using it myself on RedHat EL7 with Remi php7.

I ran into the same problem. However according to the link you provided PHP7 is in fact supported. So I’m not sure why you have so many comments telling you to go re-write your code.

This is what ultimately fixed the issue for me:

sudo apt-get install php-odbc 

Followed by restarting Apache.

PHP 7.2.7, add extension=php_odbc.dll in php.ini file while either using database as MS Access or Sql Server C:\xxxxxx\php\php.ini

*no semicolon before to extension=php_odbc.dll

Just enble «php_odbc.dll» extension by removing the semicolon and restart Apache.

If there is no such line in php.ini, simply create it on yourself (you will find many similar lines in php.ini) by adding: extension=php_odbc.dll and then restart Apache.

If Apache does not start or cannot load php_odbc.dll, look into to the ext-Folder of PHP, if there is such a DLL called php_odbc.dll. If there is no such DLL, Xampp/PHP7 does not support ODBC natively. In that case you should install an older Xampp Version with PHP 5.x

> ; Notes for Windows environments : > ; > ; - ODBC support is built in, so no dll is needed for it. > ; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+) 

But, in PHP 7, ODBC is not by default. Explicit

worked for me (new syntax recommended)

Edit: If your architecture is x64 you must use C:\Windows\SysWOW64\odbcad32.exe instead of C:\Windows\system32\odbcad32.exe

Here is the error message:

Redhat PHP Fatal error: Uncaught Error: Call to undefined function odbc_connect()

On Redhat Linux 7 you run:

You will get these packages marked in red:

enter image description here

Code sample to test your connection via php command line run: php [filename].php

 php test-connection.php $connect = odbc_connect("Driver=FreeTDS; Server=sbase.company.ca; Port=1433; TDS_Version=8; ClientCharset=UTF-8; Database=mydbase",'company\\user', 'password'); $query = "SELECT * from mytable"; // perform the query $result = odbc_exec($connect, $query); // fetch the data from the database while(odbc_fetch_row($result)) < $suid = odbc_result($result, 1); $uid = odbc_result($result, 2); $gid = odbc_result($result, 3); $name = odbc_result($result, 4); print("$name|$suid|$uid|$gid\n"); >// close the connection odbc_close($connect); ?> 

Источник

Fatal error: Call to undefined function odbc_connect()

I’ve written a script that its goal is to connect to access.This code is in cpanel and php.ini is set to enable the odbc. The code is :

;Dbq=$mdbFilename"; $UserName="root"; $Password=""; $connection=odbc_connect($Dsn,$UserName,$Password) or die(odbc_error()); ?> 

First step: Google Call to undefined function odbc_connect() You’ll find plenty of resources. However, the code you show is trying to connect to an Access file, while in the question you talk about mySQL. Which is it?

Are you able to connect the odbc using application in your local machine. If not let us know the error you are getting.

1 Answer 1

I am on Ubuntu 14.04 LTS, and has the same error message as you in log file:

PHP Fatal error: Call to undefined function odbc_connect() in /var/www/html/test-odbc.php on line 8 

To fix this error we can simply run the following command:

sudo apt-get install php5-odbc 

Here is an example of the command output:

:/etc$ sudo apt-get install php5-odbc Reading package lists. Done Building dependency tree Reading state information. Done The following NEW packages will be installed: php5-odbc 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 30.4 kB of archives. After this operation, 150 kB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main php5-odbc amd64 5.5.9+dfsg-1ubuntu4.13 [30.4 kB] Fetched 30.4 kB in 0s (34.5 kB/s) Selecting previously unselected package php5-odbc. (Reading database . 217071 files and directories currently installed.) Preparing to unpack . /php5-odbc_5.5.9+dfsg-1ubuntu4.13_amd64.deb . Unpacking php5-odbc (5.5.9+dfsg-1ubuntu4.13) . Processing triggers for libapache2-mod-php5 (5.5.9+dfsg-1ubuntu4.13) . Setting up php5-odbc (5.5.9+dfsg-1ubuntu4.13) . Creating config file /etc/php5/mods-available/odbc.ini with new version php5_invoke: Enable module odbc for cgi SAPI php5_invoke: Enable module odbc for cli SAPI php5_invoke: Enable module odbc for apache2 SAPI Creating config file /etc/php5/mods-available/pdo_odbc.ini with new version php5_invoke: Enable module pdo_odbc for cgi SAPI php5_invoke: Enable module pdo_odbc for cli SAPI php5_invoke: Enable module pdo_odbc for apache2 SAPI Processing triggers for libapache2-mod-php5 (5.5.9+dfsg-1ubuntu4.13) . 

Источник

can’t get odbc working in apache

I installed unixODBC by using apt-get install, and now when I try to use odbc_connect() is still get this error.

PHP Fatal error: Call to undefined function odbc_connect() 

what do i need to do to configure it to work with php? I have been looking online but I can’t really figure it out.

5 Answers 5

I think you need to install php5-odbc also. unixODBC provides the driver manager, but you need the PHP code that calls it.

If I install php5-odbc, do I need to do any further configuration before I can use odbc_connect()? I installed that package, but can’t get it to work. Perhaps a reboot of the machine would do it (although I don’t know when I will be able to)?

Had the same issue on CentOS 6.3 with PHP 5.3.16. But the fix was to use yum to install php-odbc.

Did you add it to your LD_LIBRARY_PATH ? Check the documentation for your server, it may require third-party libraries to be in a specific sub-directory, or have some other mechanism for finding them. If so, you should be able to create a symbolic link to the library. That way, if it gets updated, your server will automatically use it.

We had this problem also. We installed php5-odbc, and still had the problem. Turns out we needed to reboot Linux for php to see the function. Recycling Apache was not enough!

Make sure to enable odbc extension for your Apache by a2enmod odbc .

Then check if exists by: apache2ctl -M .

If you don’t have this extension, install via apt-get install php-odbc (use yum in case of CentOS).

This question is in a collective: a subcommunity defined by tags with relevant content and experts.

Источник

Читайте также:  Borders in html forms
Оцените статью