PHP OCI8 Oracle Database Connection Test Script PDF Print E-mail

This script tests a database connection to a Oracle Database using the OCI8 PHP extension.

  • Save this script as oracle.php in your root folder of your Joomla installation.
  • Modify username, password etc in the script
  • Open a web browser and load the script, e.g. http://yoursite/oracle.php

If you get a green OK echoed back then the connection was successful. If not, please stude the error messages and try to figure out what is the problem.

  1 
  2 
  3 
  4 
  5 
  6 
  7 
  8 
  9 
 10 
 11 
 12 
 13 
 14 
 15 
 16 
 17 
 18 
 19 
 20 
 21 
 22 
 23 

 24 
 25 
 26 
 27 
 28 
 29 
<?php
///////////////////////////////////////////////////
// Joomla-R-Us
//
// Connection test to external Oracle Database 
// using OCI8
///////////// Configure this /////////////////////

// TNS Instance Name, or leave blank if local/default Oracle DB
$tnsName     '';
$username     'myusername';
$password     'mypasswd';

///////////// End Configure /////////////////////


// Try connecting to the database

$conn oci_connect($username$password$tnsName);

if (!
$conn) {
      
$e oci_error();   // For oci_connect errors pass no handle
      
echo '<b><font color="red">FAILED</font></b> : ' htmlentities($e[
        'message'
]);
} else {
    echo 
'<b><font color="green">OK!</font></b>';
    
oci_close($conn);
}

?>




Comments (4)add comment

Lavanya said:

0
...
The following error is raised, when I did the same:

Fatal error: Call to undefined function oci_connect() in D:softwaresxampphtdocsjoomlaoracle.php on line 19
 
April 27, 2010
Votes: +0

Mats @ Joomla-R_Us said:

admin
...
@Lavanya: That means that you don't have the OCI8 library installed in PHP.
 
May 04, 2010
Votes: +0

kotsi said:

0
...
very nice ... helped me alot thx so much =)


1000 times thumb up
 
October 14, 2010
Votes: +0

alexin said:

alexin
...
Tengo este inconveniente al tratar de realizar el test de conexión

( ! ) Parse error: syntax error, unexpected T_STRING in C:wampwww estoracle.php on line 10


Y estoy nada mas modificando estas lineas

// TNS Instance Name, or leave blank if local/default Oracle DB
$tnsName      = 'XE';
$username     = 'EJEMPLO1';
$password     = 'abc123';

///////////// End Configure /////////////////////
 
March 17, 2011
Votes: +0

Write comment
You must be logged in to post a comment. Please register if you do not have an account yet.

busy
 
 
  Design by augs-burg.de & go-vista.de  
 
     
 
   
 

The Joomla!(R) name is used under a limited license from Open Source Matters in the United States and other countries. http://Joomla-R-Us.com is not affiliated with or endorsed by Open Source Matters or the Joomla! Project.