Page 1 of 1

[SOLVED]Newer code needs reverted to older PHP version

Posted: Mon Feb 28, 2011 10:25 am
by vaughtg
Greetings, I'm a relative n00b to PHP and this forum, so forgive my ignorance. It's why I'm here.

I have been developing code on a local machine, running a local web server, for about 10 weeks or so. Last week, my supervisor asked if I could put my code out on the development server to give them an idea of what I've done. Well, as Murphy would have it, I'm running PHP 5.3.3 on my local server and the development server is running 5.1.6 - and a lot of stuff BREAKS when deployed to the older server version. I could explain the entire situation, but it's long and boring - but suffice it to say that the IT department involved with administering the development and production servers move with glacial speed. So, my BEST option (not the best solution) is to write my code to work with their older server version.

Right now, I am having problems with the following code:

Code: Select all

            try{
               $conn = new PDO($dsn, ORA_USER, ORA_PWD);
               DBConnection::$connection = $conn;
               DBConnection::$instantiated = true;
            }catch(Exception $e){
               $this->setErrorMsg("- ERROR: constructing DBConnection <br />\n".
                     $e."<br />\n");
               die("Database connection failed. ".$e);
            }
This generates the following output:

Code: Select all

Database connection failed. Object id #4
The research that I've done has revealed that I *should* be able to do the following:

Code: Select all

            try{
               $conn = new PDO($dsn, ORA_USER, ORA_PWD);
               DBConnection::$connection =& $conn;
               DBConnection::$instantiated =& true; <<<----- This is line 23 referenced in the results below
            }catch(Exception $e){
               $this->setErrorMsg("- ERROR: constructing DBConnection <br />\n".
                     $e."<br />\n");
               die("Database connection failed. ".$e);
            }
But that generates the following:

Code: Select all

Parse error: syntax error, unexpected ';', expecting T_PAAMAYIM_NEKUDOTAYIM in <pathToMyApp>/DBConnection.php on line 23
So now I'm trying to figure out how to accomplish what I'm trying to accomplish in an older version (5.1.6) of a completely new language and I'm lost. Can anybody help me out?

Re: Newer code needs reverted to older PHP version

Posted: Mon Feb 28, 2011 10:42 am
by AbraCadaver
In your first code, try:

Code: Select all

die("Database connection failed. " . $e->getMessage());

Re: Newer code needs reverted to older PHP version

Posted: Mon Feb 28, 2011 10:54 am
by vaughtg
Thanks, AbraCadaver!!! That helped - somewhat. LOL

Here's the next output:

Code: Select all

could not find driver
So, I'm guessing the driver for the database isn't installed on the Apache instance - no?

Oh, and I get the same output when using the following code:

Code: Select all

            try{
               $conn = new PDO($dsn, ORA_USER, ORA_PWD);
               DBConnection::$connection =& $conn;
               DBConnection::$instantiated = true;
            }catch(Exception $e){
               $this->setErrorMsg("- ERROR: constructing DBConnection <br />\n".
                     $e."<br />\n");
               die("Database connection failed. ".$e->getMessage());
            }

Re: Newer code needs reverted to older PHP version

Posted: Mon Feb 28, 2011 11:10 am
by AbraCadaver
PHP will have to be configured/re-compiled to add PDO_OCI. So you may have to wait for a while. I'm not sure what alternatives there are because I always use MySQL or SQLlite.

Re: [SOLVED]Newer code needs reverted to older PHP version

Posted: Thu Apr 14, 2011 9:24 am
by vaughtg
Well, I've had to re-post this issue (hopefully stated more correctly). The solution stated here would work wonderfully, if I had the luxury of doing my own upgrades or waiting for the server admins to step up. As it is, the project is already two weeks overdue and I need this working - with or without PDO_OCI. There has GOT to be some way to figure out why the previous app was connecting to the DB and mine is not.