php connection returns error - php

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.

Related

Fatal error: Uncaught Error: Call to undefined function pg_connect() causing database not to connect to php server

I'm using php to validate forms and connect to my database but I get Fatal error: Uncaught Error: Call to undefined function pg_connect() even though I've uncommented these extension in my php.ini file
extension=pdo_pgsql
extension=pgsql
and restarted my Apache server several times. I still get the same error. I've tried everything and am now at loss. can yawl please help.
<?php
$conn= pg_connect("$host=####### $port=#### $dbname=######## $user=####### $password=######3");
if ($conn == True);
echo 'connection sucessful'
else
die (echo 'connection succesful');
?>

Call to undefined function mysqli_query() error

I keep getting this error:
Fatal error: Uncaught Error: Call to undefined function
mysqli_connect() in C:\Apache24\htdocs\asd.php:2 Stack trace: #0
{main} thrown in C:\Apache24\htdocs\asd.php on line 2
when simply running any mysqli cmd in any php file e.g :
<?php $con = mysqli_connect('localhost','my_user','my_password','my_db'); ?>
I have already enabled the extension in my php.ini file and I've been trying to figure this out for a while and I just can't.
Any help would be greatly appreciated.
Can you try this code below:
$con=mysqli_connect("localhost","my_user","my_password","my_db");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit();
}
And let me if it works thanks.

Why PHP don't see extension dll file?

I am little bit confused with strange behavior of PHP and need advice how to fix it.
I am tring to test pretty simple php script:
$conn = oci_connect($dbUser, $dbPassword, $dbServerName . "/" . $dbName);
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message']), E_USER_ERROR);
}
Unfortunatly it raise me next ERROR:
[22-Oct-2018 19:22:23] PHP Warning: PHP Startup: Unable to load dynamic library 'F:\PHP_x64\ext\php_oci8_12c.dll' - The specified procedure could not be found.
in Unknown on line 0
[22-Oct-2018 19:22:23] PHP Fatal error: Call to undefined function oci_connect() in F:\TEST\complain\test.php on line 8
I have project which is located in IIS web server. Project use PHP Version 5.6.28.
Inside F:\PHP_x64\ext\ folder I have file php_oci8_12c.dll as you can see below:
Inside php.ini file I have uncommented line:
extension=php_oci8_12c.dll
Also in php.ini file I add:
extension_dir = "F:\PHP_x64\ext\"
[PHP_OCI8_12C]
extension=php_oci8_12c.dll
I restart IIS web server several times.
When I try to call php.exe from console it show me next error:
Finally I found solution which work for me.
The code which I use to connect PHP with Oracle:
$conn = oci_connect($dbUser, $dbPassword, "(DESCRIPTION=(ADDRESS_LIST =(ADDRESS=(PROTOCOL = TCP)(HOST=$dbServerName)(PORT = 1521)))(CONNECT_DATA=(SID=$dbSID)))", 'AL32UTF8') or die("Could not connect to ORACLE");
In my case I used SID, you can also use SERVICE_NAME.

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

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.

SQLSERV in PHP7 not Working

I'm attempting to connect with a Sybase database with PHP7 on Windows Server 2012 R2 using the sqlsrv PDO driver. I've tried a number of connection strings - the following is the most direct connection string I've found that should be at least tossing me an error (an error from PHP) when accessing the page. However, when I access the page it it tells me the page is not working (as in the PHP is not working). PDO SQLSRV is active in my phpinfo(). The PHP Error I receive is:
[18-Nov-2016 22:32:18 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files\PHP\v7.0\ext\php_wincache.dll' - The specified module could not be found.
in Unknown on line 0
And many times in the same log file I am receiving the following error:
[18-Nov-2016 22:31:23 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files\PHP\v7.0\ext\php_mysql.dll' - The specified module could not be found.
in Unknown on line 0
This is all basically a straight-up install, so I'm surprised that it's tossing back errors about windows cache and mysql (when I'm not even attempting to access a mysql anything). Any leads or information would be great. Thank you for this forum!
<?php
try {
$server_name = "MY\SERVER,1234";
$database_name = "myDatabase";
$username = "myUsername";
$password = "myPassword";
$conn = new PDO("sqlsrv:server=$server_name;database=$database_name", "$username", "$password");
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
}
catch( PDOException $e ) {
die( "Error connecting to SQL Server" );
}
echo "Connected to SQL Server\n";
?>

Categories