micro_learner
asked on
PHP setting Oracle Connection : Oracle: Connection Failed: ORA-12154: TNS:could not resolve service name
Helo Evreyone... I am novice when it comes to PHP.
In need to access an Oracle database from a PHP form ..(queries will come later but I am unable to create a connection in the first place)
I have programmed iin Java JDBC before and the connection string is as below
url=jdbc:oracle:thin:@serv er:1521:db
And from The Oracle client(Toad) I connect by using the
username@server.db
I tried this with PHP but failed to connect
************************** ********** ********** ********** ********** ********** ********** ********** *****
<?php
$connection = ora_logon("username@server .db","pass word");
if ($connection == false){
echo Ora_ErrorCode($connection) .": ".Ora_Error($connection)." <BR>";
exit;
}
$cursor = Ora_Open ($connection);
if ($cursor == false){
echo Ora_ErrorCode($connection) .": ".Ora_Error($connection)." <BR>";
exit;
}
Ora_Commit ($connection);
Ora_Close ($cursor);
Ora_Logoff ($connection);
?>
************************** ********** ********** ********** ********** ********** ********** ********** *****
Thanks for your time
In need to access an Oracle database from a PHP form ..(queries will come later but I am unable to create a connection in the first place)
I have programmed iin Java JDBC before and the connection string is as below
url=jdbc:oracle:thin:@serv
And from The Oracle client(Toad) I connect by using the
username@server.db
I tried this with PHP but failed to connect
**************************
<?php
$connection = ora_logon("username@server
if ($connection == false){
echo Ora_ErrorCode($connection)
exit;
}
$cursor = Ora_Open ($connection);
if ($cursor == false){
echo Ora_ErrorCode($connection)
exit;
}
Ora_Commit ($connection);
Ora_Close ($cursor);
Ora_Logoff ($connection);
?>
**************************
Thanks for your time
ASKER
Hello ... I figured out that the earlier error was a TNSoraname error.I resolved it but I still get the error
Warning: Oracle: Connection Failed: Error while trying to retrieve text for error ORA-12514 in /home/i/html/test2.php on line 6
Oracle Connect Error Error while trying to retrieve text for error ORA-12514
I suspect that the error is due to how I am giving the connection string
say
:Username is bob
:Password is man
:Server (of DB) earth
:database name planet
if ($c=ora_logon("bob@earth", "man","pla net")) {
echo "Successfully connected to Oracle.\n";
ora_commitoff($c);
ora_logoff($c);
} else {
echo "Oracle Connect Error " . ora_error();
}
Is this right ...please guide me in this so that I can atleast get teh connection string right .
Appreciate your time and effort
Warning: Oracle: Connection Failed: Error while trying to retrieve text for error ORA-12514 in /home/i/html/test2.php on line 6
Oracle Connect Error Error while trying to retrieve text for error ORA-12514
I suspect that the error is due to how I am giving the connection string
say
:Username is bob
:Password is man
:Server (of DB) earth
:database name planet
if ($c=ora_logon("bob@earth",
echo "Successfully connected to Oracle.\n";
ora_commitoff($c);
ora_logoff($c);
} else {
echo "Oracle Connect Error " . ora_error();
}
Is this right ...please guide me in this so that I can atleast get teh connection string right .
Appreciate your time and effort
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can you post the errors your getting when running above script?
Check out this...
http://www.orafaq.com/faqphp.htm
http://www.oracle.com/technology/pub/articles/php_experts/index.html
http://www.oracle.com/technology/oramag/webcolumns/2003/techarticles/hull_php.html
http://www.oracle.com/technology/tech/opensource/php/php_troubleshooting_faq.html
Hope this helps!