The solution for not being able to connect to an Oracle database usually is setting the right system variables (ORACLE_HOME, etc...). However, it often happens that you are still not able to connect, even though these settings are correctly set.
If this is the case, try the following:
Instead of refering to the entry in the tnsnames.ora, use the actual string from the tnsnames.ora:
$User = "john"
$Password = "doe"
$Database = "(DESCRIPTION = ADDRESS_LIST (ADDRESS = (PROTOCOL= TCP (Host= yourhost) (Port= 1526)))(CONNECT_DATA = (SID = YourTnsSID )))";
OCIPLogon($User, $Password, $Database)
I hope this is helpfull for those strugling to connect to an Oracle database.
Edwin van Wijk