[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

PHP fatal error message

Asked by kmurphychi in PHP Scripting Language, PHP and Databases, PHP Frameworks

Tags: php

I am moving our sql database and files to a new server with php 5.  Our previous php is done in 4.  I am not sure what to update here, but I get the error message Fatal error: Cannot re-assign $this in /home/content/g/a/r/garrisongp/html/include/PHP_DBI.php on line 69  Below is the code for that particular file  
<?php

// $Id: PHP_DBI.php,v 1.1 2004/03/22 21:53:23 matthew Exp $

/*
 *  Database wrapper class basically, makes database calls
 *  to mysql and mssql tranparent to the other classes and functions;
 *  kinda like Perl's DBI, but not really :)
 *  
 *  This class will doubtlessly need to be extended as more functions
 *  are added to it and more database drivers are supported.
 *
 *  Found a nice way to keep this a (mostly) abstract class and not do a double
 *  method call on every call to this class! Turns out you can assign to $this
 *  in the constructor, so all we have to do is instantiate the subclass and assign
 *  it to $this, and boom, there you go. No need to keep the subclass around as
 *  a member and pass on all the method calls to it. Should speed things up significantly.
 *  
 ************************************************************************
 *
 *  HOW TO INSTANTIATE PHP_DBI OBJECTS
 *
 *  $DB = new PHP_DBI("Driver", $host, $database, $user, $password, $port, $DSN);
 *
 *  Where Driver is the name of the driver -- "Mysql", or "Pgsql" or whatever.
 *  Must match the name of the file the driver class is kept in.
 *
 *  $host will default to 'localhost'.
 *
 *  $port and $DSN are optional. The latter is used for ODBC connections.
 *
 ************************************************************************
 */

class PHP_DBI {
      /*
      * instance variables
      */
      var $dbh = 0;

      var $driver = '';
      var $sql_host = '';
      var $sql_port = 0;
      var $sql_user = '';
      var $sql_pass = '';
      var $sql_dsn = '';
      var $database = '';
      var $errno = 0;
      var $errmsg = '';
      var $error_reporting = 0;

      /*
      * CONSTRUCTOR
      * significantly different than the old monolithic Database.php. This time
      * around a connect string sort of like perl's DBI is passed in.
      * The first parameter must be the name of a driver in this same directory.
      * E.g., if you want the "Mysql" driver, the Mysql_dbd.php  file must be in
      * this directory. Or Pgsql_dbd.php or Mssql_dbd.php or whatever.
      */

      function PHP_DBI($driver, $sql_host = 'portfoliogar.db.5036119.hostedresource.com', $database, $sql_user, $sql_pass, $sql_port = 0, $sql_dsn = '') {
            if ($driver != $this->driver) {
                  $this->driver = $driver;
            }
            $DBD_name = $driver . '_dbd';
            $DBD_file = $DBD_name . '.php';
            include_once "./include/$DBD_file";

            $this = new $DBD_name($sql_host, $database, $sql_user, $sql_pass, $sql_port, $sql_dsn);
      }

      /*
      * CONNECT
      * generic connect function; connects to the server for the instantiated
      * database object
      * returns a connection object just in case it is needed
      */
      function connect() { }
 
      /*
      * PCONNECT
      * same as CONNECT; except for persistant connections
      */
      function pconnect() { }
 
      /*
      * CLOSE
      * pretty simple, just closes the connection
      * returns success or failure
      */
      function close() { }

      /*
      * DB_QUERY
      * Uses the interal db handle to submit a query to the database
      * returns the result id of the query
      */
      function db_query($sql) { }


      /*
      * FREE_RESULT
      * frees the previously obtained result set; RTFM if you need to know more
      */
      function free_result($result) { }

      /*
      * FETCH_ROW
      * just fetches a row and returns an indexed array, starting at offset 0
      */
      function fetch_row($result) { }

      /*
      * FETCH_ARRAY
      * fetches a row and returns an associative array (hash) keyed
      * on the column name
      */
      function fetch_array($result) { }

      /*
      * FETCH_OBJECT
      * fetches a row and returns an object whose members are the row's fields
      */
      function fetch_object($result) { }

      /*
      * INSERT_ID
      * takes an optional arg which is the table name
      * For MySQL, this is not required since this method
      * mimics mysql_insert_id() anyway, however, to get the same
      * information from other databases, we need a table identifier
      * PHP's postgresql driver requires the result index in order to get
      * the last insert id, so I made that an optional second argument.
      * This makes this class less generic (i.e., that's a change you'll have
      * to make in your code should you ever switch from mysql to postgres, for
      * example) but it couldn't be avoided. This method is a hack anyway.
      *
      */
      function insert_id($table = 0, $resulthandle = 0) { }

      /*
      * NUM_ROWS
      * return the number of rows in the specified result.
      * Only valid for SELECTS
      *
      */
      function num_rows($result) { }

      /*
      * AFFECTED_ROWS
      * return the affected number of rows in the specified result.
      * Only valid for INSERTS, UPDATES, and DELETES
      *
      */
      function affected_rows() { }

       /*
       * SET_ERROR_REPORTING
       * If > 0, db_query will call trigger_error itself.
       *
       */
      function set_error_reporting($new_val) {
            $this->error_reporting = intval($new_val);
      }
}

?>

line 69 which is referred to in the error is

$this = new $DBD_name($sql_host, $database, $sql_user, $sql_pass, $sql_port, $sql_dsn);
      }

Any help would be hugely appreciated as I am not familiar with php and got stranded with this.  Thanks in advance!!
[+][-]10/19/09 08:28 PM, ID: 25610866Accepted Solution

Your question has an Asker Certified™ answer! kmurphychi verified that this solution worked for them--which means it will likely work for you, too. Click to view the solution free for 30-days now.

About this solution

Zones: PHP Scripting Language, PHP and Databases, PHP Frameworks
Tags: php
Sign Up Now!
Solution Provided By: leakim971
Participating Experts: 3
Solution Grade: A
 
[+][-]10/20/09 02:51 AM, ID: 25612382Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10/20/09 06:02 AM, ID: 25613578Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10/20/09 07:24 AM, ID: 25614469Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/05/09 04:59 AM, ID: 25978797Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20100315-EE-VQP-143 - Hierarchy / EE_QW_3_20080625