When attempting to connect to an Oracle database using PHP's oci_connect() function, you may encounter the following error:
Fatal error: Call to undefined function oci_connect()
This indicates that the oci_connect() function is not available to your PHP script.
The oci_connect() function is part of the Oracle Client extension for PHP. To use this function, you must first install and enable the extension.
To resolve this issue, follow these steps:
Check if the Oracle Client extension is installed.
Open your php.ini file and search for the following line:
extension=php_oci8.dll
If this line is uncommented (no semicolon at the beginning), then the extension is installed. If not, you need to install it.
Install the Oracle Client extension.
If the extension is not installed, download the appropriate version of the Oracle Instant Client for your operating system and PHP version from Oracle's website. Then, follow the installation instructions provided.
Check if the Oracle Client DLL is copied to the correct folder.
After installing the Oracle Instant Client, ensure that the oci.dll file is copied to the PHP extension directory, typically located at:
/usr/lib/php/modules/
Restart your web server.
After making any changes to the PHP extension configuration, you must restart your web server to apply the changes.
Test your connection.
Once the Oracle Client extension is installed and enabled, you should be able to successfully call the oci_connect() function to establish a connection to your Oracle database.
The above is the detailed content of How to Resolve the \'Call to undefined function oci_connect()\' Error in PHP?. For more information, please follow other related articles on the PHP Chinese website!