PHP connection Oracle error ORA-24324 Service handle uninitialized Solution

Source: Internet
Author: User

Currently, php_oci8.dll is generally used for PHP and Oracle connections.

However, when I wrote the PHP code debugging, I encountered a strange problem, that is, only the data can be successfully obtained for the first time after each boot, but I did not try it any more and gave an error message directly.Warning: ociexecute () [function. ociexecute]: OCIStmtExecute: ORA-24324: service handle not initialized. The PHP code at that time was as follows (this code obtained data from Oracle and generated a form ):

$ OraUser = "VISITOR ";
$ Oracle ass = "123456 ";
$ OraDB = "company ";
$ Conn =OCILogon($ OraUser, $ oraPass, $ oraDB );
If (! $ Conn ){
Exit;
}
$ Stmt = OCIParse ($ conn, "select * from visitor. employee ");
If (! $ Stmt ){
Exit;
}
OciExecute ($ stmt );
Echo "<table width = 75% border = '1' cellspacing = '0' cellpadding = '1'> \ n ";
Echo "<br/> <tr> \ n <td> name </td> <td> gender </td> <td> employee ID </td> <td> salary </td> <td> Department </td> <td> Date of Birth </td> <td> company Date of entry </td> \ n </tr> \ n";
While ($ row = oci_fetch_array ($ stmt, OCI_ASSOC + OCI_RETURN_NULLS )){
Echo "<tr> \ n ";
Foreach ($ row as $ item ){
Echo "<td>". ($ item! = Null? Htmlentities ($ item, ENT_QUOTES): "& nbsp;"). "</td> \ n ";
}
Echo "</tr> \ n ";
}
Echo "</table> \ n ";
OCIFreeStatement ($ stmt );
OCILogoff ($ conn );
After reading the materials, someone found a bug in PHP5 in an inconspicuous place in an English forum,Replacing the OCILogon function with oci_new_connect can solve the problem..

At that time, it was okay.

When I did everything and apache was split, I found that some PHP Web pages missed OCILogoff after I used the database, that is, the connection was not released. I guess this is the crux of the problem, because all these PHP files are connected to the same account, resulting in conflicts, andOci_new_connectCreating a connection clearly avoids this problem.

So, I think,If all web pages are safely released after the connection is used, the above problems should be avoided.. However, I have no chance to verify it. If a comrade encounters such a problem, try it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.