chn262 Posted December 22, 2023 Share Posted December 22, 2023 Hello, i was able to load my PHP page on the web browser but got an error when run as a command line on the server. error: PHP Fatal error: Uncaught Error: Call to undefined function oci_pconnect() in ... here is my code. // Oracle database connection string $db_str = "(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = $db_host)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = $db_service_name) ) )"; // Attempt to connect to the Oracle database $conn = oci_pconnect($db_user, $db_pass, $db_str); // Check if the connection was successful if (!$conn) { $error = oci_error(); die("Connection failed: " . $error['message']); } $data = find_gate($conn); var_dump($data); // Close the database connection oci_close($conn); thank you Quote Link to comment https://forums.phpfreaks.com/topic/317563-call-to-undefined-function-oci_pconnect-when-run-php-on-server/ Share on other sites More sharing options...
gw1500se Posted December 22, 2023 Share Posted December 22, 2023 Looks like PHP was built without --with-oci8 parameter. You can install it thus: pecl install oci8 Quote Link to comment https://forums.phpfreaks.com/topic/317563-call-to-undefined-function-oci_pconnect-when-run-php-on-server/#findComment-1613728 Share on other sites More sharing options...
chn262 Posted December 22, 2023 Author Share Posted December 22, 2023 thank you, i will give that a try Quote Link to comment https://forums.phpfreaks.com/topic/317563-call-to-undefined-function-oci_pconnect-when-run-php-on-server/#findComment-1613730 Share on other sites More sharing options...
chn262 Posted January 2 Author Share Posted January 2 I already have OCI8 configured. $data = find_gate($conn); returns was able to return data (array). I was able to open the PHP file in the browser (via Apache server). but got an error when run as a command line. error: PHP Fatal error: Uncaught Error: Call to undefined function oci_pconnect() in still need some help. thanks Quote Link to comment https://forums.phpfreaks.com/topic/317563-call-to-undefined-function-oci_pconnect-when-run-php-on-server/#findComment-1613903 Share on other sites More sharing options...
gw1500se Posted January 2 Share Posted January 2 Do you have the following in your php.ini? extension=php_oci8.dll extension=php_oci8_11.g.dll Quote Link to comment https://forums.phpfreaks.com/topic/317563-call-to-undefined-function-oci_pconnect-when-run-php-on-server/#findComment-1613905 Share on other sites More sharing options...
chn262 Posted January 11 Author Share Posted January 11 i did a "grep "extension=" php.ini" here is what i got. can you help? thank you ; extension=modulename ; extension=mysqli ; extension=/path/to/extension/mysqli.so ; Note : The syntax used in previous PHP versions ('extension=<ext>.so' and ; 'extension='php_<ext>.dll') is supported for legacy reasons and may be ; move to the new ('extension=<ext>) syntax. ;extension=bz2 ;extension=ldap ;extension=curl ;extension=ffi ;extension=ftp ;extension=fileinfo ;extension=gd ;extension=gettext ;extension=gmp ;extension=intl ;extension=imap ;extension=mbstring ;extension=exif ; Must be after mbstring as it depends on it ;extension=mysqli ;extension=oci8_12c ; Use with Oracle Database 12c Instant Client ;extension=oci8_19 ; Use with Oracle Database 19 Instant Client ;extension=odbc ;extension=openssl ;extension=pdo_firebird ;extension=pdo_mysql ;extension=pdo_oci ;extension=pdo_odbc ;extension=pdo_pgsql ;extension=pdo_sqlite ;extension=pgsql ;extension=shmop ;extension=snmp ;extension=soap ;extension=sockets ;extension=sodium ;extension=sqlite3 ;extension=tidy ;extension=xsl ;extension=zip ;zend_extension=opcache Quote Link to comment https://forums.phpfreaks.com/topic/317563-call-to-undefined-function-oci_pconnect-when-run-php-on-server/#findComment-1614072 Share on other sites More sharing options...
kicken Posted January 11 Share Posted January 11 On 1/2/2024 at 12:28 PM, chn262 said: I was able to open the PHP file in the browser (via Apache server). but got an error when run as a command line. If it works in the browser, but not in the command line then you probably have different configurations for the two environments. Your system may have multiple php.ini files, one that's used for web stuff and another used for CLI scripts. The output of the phpinfo() function will tell you where the INI file being parsed is. In the php.ini output you provided, you can see all the lines being with ; which means they are all commented out and not active. Try removing the leading ; from the oci lines to enable the extension. The effect should be immediate for CLI, but may need you to restart the webserver or fpm server for webpages. Quote Link to comment https://forums.phpfreaks.com/topic/317563-call-to-undefined-function-oci_pconnect-when-run-php-on-server/#findComment-1614073 Share on other sites More sharing options...
chn262 Posted January 11 Author Share Posted January 11 hello, this is the correct output from php.ini file based in info.php i have extension=oci8.so running ; extension=modulename ; extension=mysqli ; extension=/path/to/extension/mysqli.so ; Note : The syntax used in previous PHP versions ('extension=<ext>.so' and ; 'extension='php_<ext>.dll') is supported for legacy reasons and may be ; move to the new ('extension=<ext>) syntax. ;extension=bz2 ;extension=curl ;extension=ffi ;extension=ftp ;extension=fileinfo ;extension=gd ;extension=gettext ;extension=gmp ;extension=intl ;extension=imap ;extension=ldap ;extension=mbstring ;extension=exif ; Must be after mbstring as it depends on it ;extension=mysqli ;extension=oci8_12c ; Use with Oracle Database 12c Instant Client extension=oci8.so ; Use with Oracle Database 19 Instant Client ;extension=odbc extension=openssl ;extension=pdo_firebird ;extension=pdo_mysql ;extension=pdo_oci ;extension=pdo_odbc ;extension=pdo_pgsql ;extension=pdo_sqlite ;extension=pgsql ;extension=shmop ;extension=snmp ;extension=soap ;extension=sockets ;extension=sodium ;extension=sqlite3 ;extension=tidy ;extension=xsl ;zend_extension=opcache ;zend_extension=/usr/php/8.0/lib/extensions/no-debug-zts-20200930/xdebug.so Quote Link to comment https://forums.phpfreaks.com/topic/317563-call-to-undefined-function-oci_pconnect-when-run-php-on-server/#findComment-1614074 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.