Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Sharing an Oracle connection with multiple php files

msebergJan 27 2017 — edited Jan 30 2017

PHP Version 5.4.42

oci8 Version 1.4.9

Oracle Client Version 11.2.0.1.0

------------------------------------------------------------------------------

I'm attempting to write a logon page which connects Oracle users and then redirects to another PHP file where the data is displayed etc. I do not want to hard code $username, $password or $database in any PHP file. I can pass $username, $password and $database to the second php, but this forces a second connection which I'm also trying to avoid. My connect code looks like this: ( Yes I will switch to oci_connect as I move forward )

$conn = ocilogon($username, $password, $database);

             if (!$conn) {

               $e = ocierror();

               print htmlentities($e['message']);

               exit;

        }

If I try to pass $conn I get an error stating something to the effect that $conn is a resource. I searched several of the link provided here and came up empty.

My two questions:

1. Can I pass an Oracle connection between PHP files?

2. If yes to question 1 can anybody direct me to an example or document?

Thanks!

P.S. Have also read everything I can find here:

PHP: oci_connect - Manual

This post has been answered by Christopher Jones-Oracle on Jan 29 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 27 2017
Added on Jan 27 2017
4 comments
1,532 views