Jump to content

Call to undefined function oci_pconnect() when run php on Server


chn262

Recommended Posts

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

 

 

Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
Share on other sites

  • 2 weeks later...

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
 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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
 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.