I want to connect the oracle Schema database by default that comes in the oracle bd through PDO with php but it throws me this error:
Fatal error: Uncaught PDOException: SQLSTATE[42S02]: pdo_oci_handle_factory: ORA-12154: TNS:could not resolve the connect identifier specified (ext\pdo_oci\oci_driver.c:640) in C:\xampp\htdocs\ORACLE\52conexion3.php:9 Stack trace: #0 C:\xampp\htdocs\ORACLE\52conexion3.php(9): PDO->__construct('oci:host=localh...', 'hr', 'hr') #1 {main} thrown in C:\xampp\htdocs\ORACLE\52conexion3.php on line 9
    <!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<?php
    $base = new PDO('oci:host=localhost/XE; dbname= Schema - HR', 'hr','hr');
?>
</body>
</html>
In the sql developer in the connection where is the bd of "shema" I gave a right click to see properties and that the data I entered is correct, it says Connection name: Schema - HR, user: hr, password: hr, alias of the network: XE .
Other attempts and still not working:
$base = new PDO('oci:host=localhost;dbname=Schema - HR', 'hr','hr');
$base = new PDO("oci:host=localhost;dbname=Schema - HR", "hr","hr");
$base = new PDO("oci:host=localhost/XE;dbname=Schema - HR", "hr","hr");
$base = new PDO("oci:host=XE;dbname=Schema - HR", "hr","hr");
$base = new PDO('oci:host=localhost;dbname="Schema - HR"', 'hr','hr');
I checked the .ini file and it's apparently right "extension = php_pdo_oci.dll".
NOTE: I searched the php manual and when I do not connect with pdo but through the procedure I do it in this way (using oci_connect) and it works correctly:
$ connection = oci_connect ('hr', 'hr', 'localhost / XE');
// oci_connect: resource oci_connect (string $ username, string $ password [, string $ connection_string [, string $ character_set [, int $ session_mode]])
hostshould be the name of the host, which should be a (DNS) resolvable name; it shouldn't contain slashes. - elixenidedbname=param: php.net/manual/en/ref.pdo-oci.connection.php - mario