PHP Wordpress odbc_connect() : "Error: Call to undefined function odbc_connect()"

Viewed 18

I have a custom plugin in Wordpress 6.0.2, programmed with PHP 8.1.

When I run the function:

$conn = odbc_connect($DNS, "", "");

Returns the following error:

Error: Call to undefined function odbc_connect()

The server where the website (and the plugin) is hosted has the Linux Ubuntu 18.04 operating system.

I have installed all the necessary dependencies and libraries (and more), but it keeps showing the same error all the time:

sudo apt-get install libc6 libstdc++6 zlib1g libgcc1

sudo apt-get install unixODBC unixODBC-dev

sudo apt-get install php-odbc or sudo apt-get install php8.1-odbc

Everything is installed correctly, the driver too (and it is also configured correctly):

Configuration

The code is correct, it works locally. And the error has nothing to do with the Driver or the connection parameters. It has to do with it not detecting the "odbc_connect()" function.

What can be the solution? Does anyone have any idea what might be missing?

Thanks.

1 Answers

I think the problem here is that you're using odbc_connect. Try odbc_pconnect, maybe it's better for servers.

Related