IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

Ora-12154 [Oracle]


Sujet :

PHP & Base de données

  1. #1
    Membre du Club
    Inscrit en
    Septembre 2003
    Messages
    112
    Détails du profil
    Informations forums :
    Inscription : Septembre 2003
    Messages : 112
    Points : 52
    Points
    52
    Par défaut Ora-12154
    Bonjour a tous,
    Je viens d'installer Apache 1.3.34 et php 4.4.1
    avec l'extension oci8 sous linux.

    J'ai aussi installé un client oracle 10g.

    J'arrive parfaitement a me connecter a ma base ORACLE 10g avec SQLPLUS.

    mais lorsque j'essai de me connecter avec une page php j'ai l'erreure suivante:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    Warning: ocilogon(): _oci_open_server: Error while trying to retrieve text for error ORA-12154 in /usr/local/apache/htdocs/testoci.php on line 1
    Oracle Connect Error
    L'origine de l'erreure 12154 semble provenir de mon TNSNAME mais si ca fonctionne par sqlplus, y'a pas de raisons???

    Voici les sources de mon test de connection:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <?php if ($c=OCILogon("login", "pass", "SIDmabase"))
    {
    	echo "Successfully connected to Oracle.\n"; OCILogoff($c);
    }
    else { 
    	$err = OCIError(); 
    	echo "Oracle Connect Error " . $err[text]; 
    } 
    ?>
    MERCI D'AVANCE!

  2. #2
    Membre du Club
    Inscrit en
    Septembre 2003
    Messages
    112
    Détails du profil
    Informations forums :
    Inscription : Septembre 2003
    Messages : 112
    Points : 52
    Points
    52
    Par défaut
    j'viens de passer mon aprem dessus.
    J'trouve pas.

    Pourtant la connection se fait bien par sqlplus...

    Des idées??? merci

  3. #3
    Membre éprouvé
    Inscrit en
    Juillet 2004
    Messages
    1 027
    Détails du profil
    Informations forums :
    Inscription : Juillet 2004
    Messages : 1 027
    Points : 1 164
    Points
    1 164
    Par défaut
    Alala heureusement google est la sinon qui s'en servirait...

    http://66.102.9.104/search?q=cache:cLb2h4aL_OUJ:gokmen.selcuk.edu.tr/tutor/orasol/ociphp.php+ORA-12154+php&hl=fr
    ESCAPING FROM OCI() ERRORS
    I assume that you have already a PHP file for use to connect Oracle. Create or Copy any one of them into "DocumentRoot" ("/usr/local/apache/htdocs" in here) and try to run it in your browser.

    I hope you did not get an error like

    Warning: ocilogon(): _oci_open_server: Error while trying to retrieve text for error ORA-12545 in ....
    This error is telling you did not specify "ORACLE_SID" in your script or

    Warning: ocilogon(): _oci_open_server: Error while trying to retrieve text for error ORA-12154 in ...
    This error could not find any match "ORACLE_SID" you specified in "TNSNAMES.ORA" file.

    If you got one of these error, your environment variables must introduce to your apache web server.

    Remember that you compiled apache with Oracle user and group. So, do the following:

    create a file named "oraenv" in "/usr/local/apache/conf/" directory and put the following lines in it:

    (IMPORTANT : Please change <ORAHOME> with $ORACLE_HOME and <ORASID> with $ORACLE_SID environment variables of your Oracle user..)

    Here is an example for this "oraenv" file:

    LD_LIBRARY_PATH=/opt/oracle/product/8.1.7/lib:/usr/local/apache/lib:/usr/local/lib
    ORACLE_HOME=/opt/oracle/product/8.1.7
    ORACLE_SID=/opt/oracle/product/8.1.7
    TNS_ADMIN=/opt/oracle/product/8.1.7/network/admin
    NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1 #for English
    #NLS_LANG=TURKISH_TURKEY.WE8ISO8859P9 #for Turkish
    ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
    If you want You may insert these lines into "/usr/local/apache/bin/apachectl" file directly.

    Now You need to edit "/usr/local/apache/bin/apachectl" file. Open it by a text editor and add the following lines to anywhere in the "CONFIGURATION SECTION"

    if [ -f /usr/local/apache/conf/oraenv ] ;
    then
    . /usr/local/apache/conf/oraenv
    fi
    IMPORTANT NOTES :

    Make sure Oracle Listener and Oracle Database have already started while Apache Server starting/restarting.
    "oraenv" file will be included in all attempting to start or restart apache web server. Don't delete this file anyway.)
    In all of your php scripts, you need to add "ORACLE_SID" at connection line like (Replace "orcl" with your ORACLE_SID.) I recommend you to use a connection function as follows and require it in your scripts:
    <?

    class oraClass
    {
    var $sql, $stmt, $conn, $nrows, $ncols, $errmsg, $user, $pass;


    function db_connect()
    {
    if($this->conn = OCILogon($this->user, $this->pass, $_ENV['ORACLE_SID']))
    $this->db_parse();
    else
    $this->get_error($this->conn);
    }
    .
    .
    .
    ?>

    Now you can use your great database with your great web development language.

    If you have any question or suggestions drop an email to my mailbox.

    I hope this tutorial will help you too...

  4. #4
    Membre du Club
    Inscrit en
    Septembre 2003
    Messages
    112
    Détails du profil
    Informations forums :
    Inscription : Septembre 2003
    Messages : 112
    Points : 52
    Points
    52
    Par défaut
    Merci pour ta réponse.
    J'ai tout lu, tout essayé et rien a faire.

    Par contre, j'ai fait un test en précisant directement l'ip, le sid... comme dans le fichier tnsnames.ora

    et là ca marche!

    j'en déduis que cela viens de ma config TNS mais avec SQLPLUS ca fonctionne parfaitement.
    d'autres pistes?
    Merci d'avance

    Version qui fonctionne:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <?php
    if ($c = OCILogon('sugarcrm', 'mba', '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)
    (HOST=xxx.xxx.xxx.xxx) (PORT=1521)))
    (CONNECT_DATA=(SERVICE_NAME=ORCL)))'))
    {
    	echo "Successfully connected to Oracle.\n"; 
    	OCILogoff($c); 
    } else { 
    	$err = OCIError(); 
    	echo "Oracle Connect Error " . $err[text];	
     } 
    ?>
    Celle qui affiche l'erreure:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <?php
    if ($c=OCILogon("sugarcrm", "mba", "SIDbase"))
    {
    	echo "Successfully connected to Oracle.\n"; 
    	OCILogoff($c); 
    } else { 
    	$err = OCIError(); 
    	echo "Oracle Connect Error " . $err[text];	
     } 
    ?>
    alors que dans le tnsnames.ora c'est ecrit:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    SIDbase=
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xxx.xxx.xxx)(PORT = 1521))
        )
        (CONNECT_DATA =
          (SERVICE_NAME = ORCL)
        )
      )
    Mes variables d'environnement définit dans le /root/.bashrc:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    # environnement ORACLE
    ORACLE_BASE=/home/oracle
    ORACLE_HOME=/home/oracle/ORACLT10
    ORACLE_SID=ORCL
    ORACLE_TERM=vt100
    TNS_ADMIN=/home/oracle/ORACLT10/network/admin/
     
    PATH=$ORACLE_HOME/bin:$PATH
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:$ORACLE_HOME/network/lib:usr/local/lib:/usr/local/apache/lib
    export TNS_ADMIN ORACLE_BASE ORACLE_HOME ORACLE_SID ORACLE_TERM LD_LIBRARY_PATH PATH
    Merci d'avance. je desespere là...

  5. #5
    Membre du Club
    Inscrit en
    Septembre 2003
    Messages
    112
    Détails du profil
    Informations forums :
    Inscription : Septembre 2003
    Messages : 112
    Points : 52
    Points
    52
    Par défaut
    j'ai enfin trouvé,

    j'ai copier le tnsname.ora dans le rep /usr/local
    et j'ai déclaré la variable d'environnement
    TNS_ADMIN=/usr/local

    Il semblerai qu'apache n'ai pas les droit pour acceder au tnsnames.ora si il se trouve dans /home/oracle/ORACLT10...

  6. #6
    Membre à l'essai
    Inscrit en
    Novembre 2006
    Messages
    28
    Détails du profil
    Informations forums :
    Inscription : Novembre 2006
    Messages : 28
    Points : 16
    Points
    16
    Par défaut
    j'ai le meme probleme et j'ai essayer la derniere solution ... cela ne marche pas pourtant sous windows pas de probleme cela ne vien donc pas du site... mon sqlplus marche tres bien aussi ... j'ai mis le /etc/oracle en 777 ainsi que le tnsnames.ora qui si trouve pour tester mais cela ne change rien et dans /usr/local non plus... help please

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 4
    Dernier message: 31/01/2006, 17h59
  2. [Forms 10g] ORA-12154
    Par zinabd dans le forum Oracle
    Réponses: 6
    Dernier message: 11/01/2006, 01h29
  3. [10.2.0][client](OCI_ERROR) : ORA-12154 mais tnsping ok
    Par neo.51 dans le forum Connexions aux bases de données
    Réponses: 4
    Dernier message: 05/10/2005, 17h47
  4. Réponses: 11
    Dernier message: 29/06/2005, 11h36
  5. BD LINK erreur ORA-ORA-12154
    Par de LANFRANCHI dans le forum Oracle
    Réponses: 8
    Dernier message: 15/02/2005, 15h39

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo