PHP cannot connect to oracle in WAMP

theskintman
theskintman used Ask the Experts™
on
Hello experts,

I am using a Windows 7 machine, and have installed WAMP (www.wampserver.com/en/) on it.

I can connect to Oracle through SQL*Plus and SQL Developer. I have also created a test PHP script to connect to Oracle, which works when using the PHP command line. However, when I try running the same PHP script through Apache (i.e. typing 'http://localhost/oracletest.php' into the browser) it will not work, resulting in a "ORA-12154: TNS:could not resolve the connect identifier specified" error.

I have made sure that Windows firewall allows apache, wampservermanager.exe and php.exe. I have enabled OCI8 PHP extension, installed an oracle client, made sure the path to the client is in the windows environment variable path.

I would be very grateful to anyone with any idea as to what is causing this!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Administrator
Top Expert 2005
Commented:
Very often there is this issue because you are running apache as a different user (system) than you (user).

so open services.msc select apache, right click to properties, select the logon tab, select this account, enter you credentials, ok, stop the service, start the service, check if it's running, then try again.

YMMV, I'm using a non english windows, might have other descriptions on it.

21-10-2010-07-03-11.png

Author

Commented:
Thanks for your help Tolomir - I took these steps but it is still not working - do you have any other suggestions?
TolomirAdministrator
Top Expert 2005

Commented:
Please take a look at:

Thread: Help with WAMP and ORA-12154 error                        
http://forums.oracle.com/forums/thread.jspa?threadID=997500&tstart=121




Author

Commented:
Thanks again for your help Tolomir - I have solved the problem. The problem was that there was no tnsnames.ora in the $ORACLE_HOME/network/admin folder! Not sure why it wasn't there, and why I was able to connect through SQL*PLUS and PHP without it, but it all seems to work now!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial