Fatal error: Uncaught Error: Call to undefined function oci_connect() - php

I am having problems with oci_connect() in PHP. I can't connect with an Oracle Database, after I had installed the Oracle InstantClient(32 Bit) and copied the required *.dll's in the apache/bin/ and xampp/php folders.
I get this:
Fatal error: Uncaught Error: Call to undefined function oci_connect()
in C:\xampp\htdocs\OracleTest\connect.php:9 Stack trace: #0 {main}
thrown in C:\xampp\htdocs\OracleTest\connect.php on line 9.
There is also the Problem that I am unable to load the dynamic libraries:
PHP Warning: PHP Startup: Unable to load dynamic library
'C:\xampp\php\ext\php_oci8_11g.dll' - The specified module could not
be found. in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library
'C:\xampp\php\ext\php_oci8_11g.dll' - The specified module could not
be found. in Unknown on line 0
My Code is this:
$oc_conn = oci_connect('127.0.0.1/XE','****', '****');
if($oc_conn)
{
echo "Success!!!";
}
else
{
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
I am struggling on that Problem for over 3 weeks..I really need help, thank you in advance.

The "Call to undefined function oci_connect()" seems to be a secondary error resulting from a root cause error. The root cause error, as the error message says, seems to be that PHP cannot find the file named C:\xampp\php\ext\php_oci8_11g.dll. PHP will get this file name from the extension=php_oci8_12c.dll statement in your php.ini. It also seems that your php.ini has defined C:\xampp\php\ext\ as the place where extension code should be located.
FIX: Make sure the .dll is in C:\xampp\php\ext\, not just apache/bin. Also, make sure the name of the .dll is php_oci8_11g.dll, not oci.dll.
Successfully loading a dynamic library / extension will (usually) make new functions and classes available to your PHP code. Once you've got php_oci8_11g.dll loaded, you'll probably find that the oci_connect() error is fixed too.

Related

Using WAMP to connect to SQL Server

I've read a lot of posts here on this problem, but I think mine is a little different because the output I'm getting doesn't match what others have had.
I am running WampServer Version 3.1.4 64bit and trying to connect to a SQL Server DB and I get the following error:
Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect()
using the following code:
$serverName = "xxx.xxx.xxx.xxx";
$connectionInfo = array("Database" => "db_name", "UID"=>"sa", "PWD"=>"db_pwd");
$conn = sqlsrv_connect($serverName, $connectionInfo);
I have tried the following:
I downloaded the sql drivers for PHP 7 and 7.1 and tried them with the corresponding PHP versions
I made sure to restart all services after updating the php.ini file.
With my version of WAMP the php.ini file in the Apache folder is just a shortcut to phpForApache.ini in the php7.1.22 folder and it updates automatically.
The extensions DO show up in the WAMP menu: PHP > PHP extensions
and they have the green check mark next to them
I consistently get the following in my php_error.log:
[27-Nov-2018 14:25:16 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp64/bin/php/php7.1.22/ext/php_sqlsrv_71_nts.dll' - %1 is not a valid Win32 application.
in Unknown on line 0
[27-Nov-2018 14:25:16 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp64/bin/php/php7.1.22/ext/php_sqlsrv_71_ts.dll' - %1 is not a valid Win32 application.
in Unknown on line 0
As stated, I've tried using the appropriate dlls for both php 7 and 7.1.22 and got the same output:
[27-Nov-2018 15:12:37 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp64/bin/php/php7.0.32/ext/php_sqlsrv_7_ts_x86.dll' - %1 is not a valid Win32 application.
in Unknown on line 0
[27-Nov-2018 15:12:37 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp64/bin/php/php7.0.32/ext/php_sqlsrv_7_nts_x86.dll' - %1 is not a valid Win32 application.
I'm really not sure what other config I must be missing. I also tried the x64 versions, but I get an error stating the file could not be found, even though I triple checked the location.
Seeing as I get the same not a valid Win32 application error for both versions, I guess it's something outside of PHP

Using composer with php in non standard location

I'm trying to use composer on my NAS (a good old D-Link DNS-323 running the incredibly good fonz fun plug 0.7).
I have my php installed in /ffp/bin/php.
When I install composer using the following command
php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/ffp/sbin --filename=composer
But when I do a simple less /ffp/sbin/composer, I have the following shebang set :
#!/usr/bin/env php
<?php
/*
* This file is part of Composer.
*
Unfortunatly, my NAS do not have the /usr/bin/env folder existing on my machine ...
So, how can I have composer referring to the correct php executable ?
Besides, I tried changing the declaration to use #!/ffp/bin/php, but when doing so, any composer run echoes the following result :
PHP Warning: PHP Startup: Unable to load dynamic library '/ffp/lib/php/extensions/no-debug-non-zts-20100525/gd.so' - File not found in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/ffp/lib/php/extensions/no-debug-non-zts-20100525/gd.so' - File not found in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/ffp/lib/php/extensions/no-debug-non-zts-20100525/sqlite.so' - File not found in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/ffp/lib/php/extensions/no-debug-non-zts-20100525/sqlite.so' - File not found in Unknown on line 0
PHP Fatal error: Uncaught exception 'PharException' with message 'phar "/mnt/HD_a2/ffp/sbin/composer" has a broken signature' in /mnt/HD_a2/ffp/sbin/composer:23
Stack trace:
#0 /mnt/HD_a2/ffp/sbin/composer(23): Phar::mapPhar('composer.phar')
#1 {main}
thrown in /mnt/HD_a2/ffp/sbin/composer on line 23
Fatal error: Uncaught exception 'PharException' with message 'phar "/mnt/HD_a2/ffp/sbin/composer" has a broken signature' in /mnt/HD_a2/ffp/sbin/composer:23
Stack trace:
#0 /mnt/HD_a2/ffp/sbin/composer(23): Phar::mapPhar('composer.phar')
#1 {main}
thrown in /mnt/HD_a2/ffp/sbin/composer on line 23
Of particular importance is the line
PHP Fatal error: Uncaught exception 'PharException' with message 'phar "/mnt/HD_a2/ffp/sbin/composer" has a broken signature' in /mnt/HD_a2/ffp/sbin/composer:23
How can i fix it ? In other words, how can I have a working php + composer installation on my NAS ?
So, how can I have composer referring to the correct php executable ?
A very simple solution is to create a shell script:
#!/bin/sh
/ffp/bin/php -n /ffp/sbin/composer "$#"
Make it executable, name it composer, put it in your path before /ffp/sbin (or rename /ffp/sbin/composer to composer.phar and update the above script too).
The -n flag tells PHP to not use php.ini. This is useful when there are many extensions loaded from php.ini; not loading them makes composer run faster. Especially xdebug is recommended to not be loaded by composer, for speed improvement.

error while running mongodb php program

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212+lfs/mongo.so' - /usr/lib/php5/20121212+lfs/mongo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Fatal error: Class 'MongoClient' not found in /var/www/exhange/b1_functions.php on line 8
This is the error popped up when running a monogdb php program in ubuntu. How can I fix that?

php connection returns error

I have a php file(conn.php) which has the following contents:
<?php
$conn = oci_connect('mdl_img_tst', 'mdl_tst_usr', 'draa.uofl.com');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
?>
Running this from the command line it returns following two errors:
Failed loading /usr/lib/php/extensions/no-debug-non-zts-20090626/5.3/xdebug.so: dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/5.3/xdebug.so, 9): image not found
PHP Fatal error: Call to undefined function oci_connect() in /Users/crdc/Sites/conn.php on line 5
What could be the possible reason for that?
UPDATE: I added a line extension=oci8.so and now there is a different error. Now it seems like oci8 is installed correctly but it has some problem with connection string.
PHP Warning: oci_connect(): ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA in /Users/crdc/Sites/conn.php on line 5
PHP Fatal error: ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA in /Users/crdc/Sites/conn.php on line 8
Any idea on that?
I would recommend verifying that OCI8 has actually been loaded by PHP.
Run this script
<?php
phpinfo();
?>
And verify that OCI8 is shown as a loaded plugin.

Call to undefined function sqlite_open

Searched already on many sites with no results. PHP keeps on saying:
Call to undefined function sqlite_open()
If I manually load sqlite (it's already installed with yum install php-pdo) I get
PHP Warning: Module 'PDO' already loaded in Unknown on line 0
PHP Warning: Module 'pdo_sqlite' already loaded in Unknown on line 0
PHP Warning: Module 'sqlite3' already loaded in Unknown on line 0
PHP Fatal error: Call to undefined function sqlite_open() in /home/kpark/dbconnect.php on line 9
sqlite_open was the function in the sqlite2 extension. What you've installed is probably the sqlite3 module, which requires sqlite3::open() instead.
But you should not use the native interface either way. Use PDO to open sqlite databases. http://www.php.net/manual/en/ref.pdo-sqlite.php

Categories