Oracle Connection error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
probkid
Forum Newbie
Posts: 10
Joined: Thu Jun 20, 2002 9:03 am

Oracle Connection error

Post by probkid »

Hi,
I am receiving the following error when i try to connect to oracle from my php4.2.1/win2k/iis env.

Warning: ociparse(): supplied argument is not a valid OCI8-Connection resource in

The code that is giving this error is:

$conn1 = OCINLogon($uname1, $password1, $db1) || die("Error on connection");

$stmt = OCIParse($conn1, "select sysdate from dual");

OCIExecute($stmt, OCI_DEFAULT) || die("Error on execute");

The error is happening after the OCIParse and not after OCINLogon. I tried using the variable strings directly and still it did not work.
Any ideas as to why this could be happening??? Also, I have included the oci dll and mapped it properly in the php.ini.
An early response would be greatly appreciated!!

Thanks alot!!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You should try using OCIError():

Code: Select all

$conn1 = OCINLogon($uname1, $password1, $db1) or die('Error on connection<br />'.OCIError());
$stmt = OCIParse($conn1, "select sysdate from dual") or die(OCIError());
Mac
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

Warning: ociparse(): supplied argument is not a valid OCI8-Connection resource in
It is not happening after ociparse, it is telling you it doesn't have a connection to the database.

I trust you have the Oracle client on your php server? and that you can tnsping your database from the command line? and your variables $uname1, $password1 and $db1 contain the correct information. Try using strings rather than variables in your connection, just for testing

OCILogon("user","password","SID");

It take it you need to use OCINLogin because you want to separate transactions, rather than OCILogon.
probkid
Forum Newbie
Posts: 10
Joined: Thu Jun 20, 2002 9:03 am

Post by probkid »

Thanks twigletmac!!
'||' seemed to be the problem. I tried it with 'or' and it worked with and without the OCIError().
Hopefully, I shouldn't have problem getting my data from oracle now. I've been having a tough time yesterday with all installation errors and today with OCIErrors on which I could hardly find any documentation.

Mikeq, Thanks for your reply but as I mentioned in my post, I had tried your solution earlier.

Thanks!!
Post Reply