|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-03-07 22:36 UTC] madlybad at hotmail dot com
Description:
------------
My configuration to connect to Oracle 9i is correct. I am able to connect to Oracle 9i using SQLPLus and TOAD. But using PHP I am unable to connect to Oracle this error appears "ORA-12154: TNS:could not resolve the connect identifier specified".
Reproduce code:
---------------
<?php
$conexion = oci_pconnect('TIENDAS','tiendas','DAVID');//('hr', 'hr', 'orcl');
if (!$conexion) {
$e = oci_error();
echo "Error al Conectarse";
print htmlentities($e['message']);
exit;
}
$consulta = 'SELECT * FROM promotoras_tda';
$id_sentencia = oci_parse($conexion, $consulta);
if (!$id_sentencia) {
$e = oci_error($conexion);
echo "Error al Parsear";
print htmlentities($e['message']);
exit;
}
$r = oci_execute($id_sentencia, OCI_DEFAULT);
if (!$r) {
$e = oci_error($id_sentencia);
echo "Error al Ejecutar la Conuslta";
echo htmlentities($e['message']);
exit;
}
print '<table border="1">';
while ($fila = oci_fetch_array($id_sentencia, OCI_RETURN_NULLS)) {
print '<tr>';
foreach ($fila as $item) {
print '<td>'.($item?htmlentities($item):' ').'</td>';
}
print '</tr>';
}
print '</table>';
oci_close($conexion);
?>
Expected result:
----------------
connected!
Actual result:
--------------
ORA-12154: TNS:could not resolve the connect identifier specified
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 14 03:00:01 2025 UTC |
Using this code I fixed the problem: $db = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) (HOST = host.com)(PORT=1521)) (CONNECT_DATA=(SERVER=DEDICATED) (SERVICE_NAME=MYDB)))"; $conexion = oci_pconnect("user","password",$db); But I have to use oci_pconnect() and not oci_connect. If I used oci_connect(), PHP CGI crash. I would like to know why. Or maybe open a new Bug about this. Please let me know is I should open it.