php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36649 ORA-12154: using Oracle 9i
Submitted: 2006-03-07 22:36 UTC Modified: 2006-03-08 13:10 UTC
From: madlybad at hotmail dot com Assigned:
Status: Closed Package: OCI8 related
PHP Version: 5.1.2 OS: Windows XP Pro SP2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: madlybad at hotmail dot com
New email:
PHP Version: OS:

 

 [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):'&nbsp;').'</td>';
       }
       print '</tr>';
  }
  print '</table>';

  oci_close($conexion);
?> 

Expected result:
----------------
connected!

Actual result:
--------------
ORA-12154: TNS:could not resolve the connect identifier specified

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-08 07:23 UTC] cjbj at hotmail dot com
The bug system is not the best place to ask this question.

Refer to notes like http://www.oracle.com/technology/tech/php/htdocs/php_troubleshooting_faq.html
and check all your environment variables - e.g. ORACLE_HOME - are set correctly in the shell environment that starts the web server.
 [2006-03-08 08:23 UTC] tony2001@php.net
The error you get comes from Oracle client libs -> not PHP problem.
 [2006-03-08 13:10 UTC] madlybad at hotmail dot com
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.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Mar 12 04:01:30 2025 UTC