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/garris
ongp/html/
include/PH
P_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.h
ostedresou
rce.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_v
al) {
$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!!