Reputation:
<?php
echo "hello";
$db='(DESCRIPTION = ADDRESS = (PROTOCOL = TCP)(HOST = some_ip)(PORT = some_port))(CONNECT_DATA = (SID = xxx.yyy)))';
$conn=oci_connect('user','pass','$db');
if (!$conn){
echo "No connection";
}
else{
echo "Connected!";
}
?>
I got the above code. It displays hello but anything else, and I don't know why, because even if the connection failed, it should display "No connection", shouldn't it?
Upvotes: 1
Views: 72
Reputation: 68546
Variables under single quotes will not be parsed !
Change this
$conn=oci_connect('user','pass','$db');
to
$conn=oci_connect('user','pass',$db); //<--- Removed the single quotes around the variable!
As Alvaro G Vicario
mentioned .. you need to enable the error reporting on your PHP code.
Add this on top of your code.
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
You need to enable the oci
extension. Go to your PHP.ini and uncomment these lines by removing the semicolon before them , save the file and restart your webserver
;extension=php_oci8.dll
;extension=php_oci8_11g.dll
Upvotes: 7