Jump to content

Recommended Posts

Hi all,

 

I installed oracle client and compiled php with oracle home but still it provides me this output below:

Fatal error: Call to undefined function OCILogin() in /usr/local/apache/htdocs/oratest.php on line 3

 

oratest.php

------------

<?php

$conn = OCILogin ("","");

?>

 

 

the ORACLE_HOME variable is set also. PHP compiled option:

/configure' '--prefix=/usr/local/php' '--with-apxs2=/usr/local/apache/bin/apxs' '--with-config-file-path=/usr/local/php' '--with-gd' '--with-gdbm' '--with-mysql=/usr/local/mysql' '--with-libxml-dir=/usr/local/packages/libxml2' '--enable-force-cgi-redirect' '--disable-cgi' '--with-gettext' '--with-zlib' '--with-sqlite' '--enable-pdo' '--with-pdo-sqlite' '--with-pdo-mysql=/usr/local/mysql' '--with-png-dir=/usr/local/packages/libpng' '--with-oci8=/opt/oracle/product/client'

 

Any help.

Yes, it does have.

 

I compiled it with both oracle and mysql.

oci8
OCI8 Support  enabled  
Version  1.2.5  
Revision  $Revision: 1.269.2.16.2.43 $  
Active Persistent Connections  0  
Active Connections  0  
Oracle Version  10.1  
Compile-time ORACLE_HOME  /opt/oracle/product/client  
Libraries Used  no value  
Temporary Lob support  enabled  
Collections support  enabled  

Directive Local Value Master Value 
oci8.default_prefetch 10 10 
oci8.max_persistent -1 -1 
oci8.old_oci_close_semantics 0 0 
oci8.persistent_timeout -1 -1 
oci8.ping_interval 60 60 
oci8.privileged_connect Off Off 
oci8.statement_cache_size 20 20 

It shows this message

 

Warning: ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory in /usr/local/apache/htdocs/oratest.php on line 2

One more thing. If I run it from shell then it gives me this message

Warning: ocilogon(): ORA-12162: TNS:net service name is incorrectly specified in /usr/local/apache/htdocs/oratest.php on line 2

 

The code is:

<?php
$conn=OCILogon("","");

?>

Ok I am confused.

 

The oracle team of ours installed the client and my part was to compile apache,php with mysql and oracle support which I did as my post. Now what is instant client and how to use that to connect to oracle server?

 

Whats the prob with the below fucntion in code?

I also made daemon user a member of group oinstall but still doesn't work.

tanveer,

  Here's something you should probably know about Oracle if you don't already, and that is that you can make an account on the Oracle Technology Network (OTN) which will give you access to oracle software, forums and information.

 

The Oracle instant client for linux basically is a package that makes it much easier than it was previously to get the Oracle client libraries installed.  If the admins already installed the oracle client the traditional way, using the oracle universal installer, then you need to have the apache process in the oracle group so that it can see the files it will need to do the client networking.

 

As for your error, I'm not sure what it is.  Please paste in the exact code you're using.  You can of course block out any passwords and ip's or domain names with *** but I am not sure what your test code is doing.  In your example above you were calling ocilogon with no connect string, so of course that won't work.  I'm assuming here, that you actually have something different, but you've not pasted the code.

Hello,

Thanks for your replies.

I already set the apache user under oracle group.

[root@localhost ~]# groups daemon
daemon : daemon bin adm lp oinstall
[root@localhost ~]# groups oracle
oracle : oinstall dba

 

Oracle users .bash_profile sample

export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product/client
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
alias cls='clear'

PATH=$PATH:$ORACLE_HOME/bin
export PATH

 

 

 

Well that looks fine then, of course you need to restart apache after a change like that with: service httpd restart

 

Any luck since then?  If not, will need to see your code to offer any further help.

 

 

Yes, I restarted the service but still same.

From browser it gives message like:

Warning: ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory in /usr/local/apache/htdocs/oratest.php on line 7

 

And if run from shell then it gives this:

Warning: ocilogon(): ORA-12154: TNS:could not resolve the connect identifier specified in /usr/local/apache/htdocs/oratest.php on line 7

 

 

Now what is this TNS and does this means anything needs to be done like database settings in some oracle files?

 

Further I can't download the instant client as its giving me errors every time.

 

One more thing, what the diff between OCILogon and oci_pconnect?

And my test code:

 

<?php

$user="user";
$password="passwd";


$conn =OCILogon($user, $password, "10.10.xx.xx/testms");

     if ($conn) {
           echo "Success";

          }else{

          $e = oci_error();  
          echo $e;

}

?>

Ok, so the problem is that oracle has it's own networking protocol and naming system called TNS.  Typically you set up entries for this in the TNSNAMES.ORA file.  It's a kind of arcane LISP like syntax.  Once you have a valid TNSNAMES entry for the server you're trying to attach to, you can try to use the simplified connect string you're attempting to utilize, but the problem looks to me like there's no such entry.  You can try to feed the entry to it in the connect string parameter.  You must know the SID of the server, which it looks like you did ('testms').

 

You can try this:

 


$db = "
(DESCRIPTION =
     (ADDRESS =
        (PROTOCOL = TCP)
        (HOST = 10.10.XXX.XXX)  // your serverIP
        (PORT = 1521)       
     )
         (CONNECT_DATA =(SID = testms))
)";

$conn = OCILogon($user, $password, $db) or die (ocierror());

 

In regards to ociLogon vs. pconnect, pconnect makes a persistent connection.  Unlike mysql, the oracle login process is very heavy, and can take a long time.  To get decent performance out of oracle, you need to use persistent connections. 

 

HI,

I used your code and now its showing no warnings or error in browser. But in apache log I am getting this:

 

[Tue Jun 30 18:06:06 2009] [error] [client 10.10.x.xx] PHP Warning:  ocilogon() [<a href='function.ocilogon'>function.ocilogon</a>]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory in /usr/local/apache/htdocs/test.php on line 13

 

Code:

<?php

 

$db = "

(DESCRIPTION =

    (ADDRESS =

        (PROTOCOL = TCP)

        (HOST = 10.10.xx.xx)  // your serverIP

        (PORT = 1521)

    )

        (CONNECT_DATA =(SID = PRODQC))

)";

 

$conn = OCILogon("user", "password", $db) or die (ocierror());

 

What is difference between SID and SERVICE_NAME in CONNECT_DATE section?

 

It displays nothing.

It doesn't even echo the word 'ORACLE_HOME='

 

You must have a syntax error.  It will display something when it works properly.  Check your apache error log to see what the issue is.

Thanks a lot for all the support.

Its solved now. What I did was first set the ORACLE_HOME environment variable and then recompile the PHP again with that ORACLE_HOME and set the ORACLE_HOME variable in /etc/profile for all users.

The DBA team did some tweaking on tnsnames.ora and it started working.

No worries, glad you got it working.  You might mention to them for any future machines that the instant client is a better way to go for machines that will connect to an instance running on another machine.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.