Wierd error.

Hey Guys,

Hoping I can get a bit of help with this error:

Deprecated: Assigning the return value of new by reference is deprecated in …\db\Database.php on line 6

Notice: Could not connect to server in …\db\Database.php on line 38

Here is the code:
[php]$host = ‘127.0.0.1’;
$user = ‘something’;
$pass = ‘somethingelse’;
$name = ‘signout’;
$db =& new MySQL($host,$user,$pass,$name);

class MySQL {

var $host;
var $dbUser;
var $dbPass;
var $dbName;
var $dbConn;
var $connectError;

function MySQL ($host,$dbUser,$dbPass,$dbName) {
    $this->host=$host;
    $this->dbUser=$dbUser;
    $this->dbPass=$dbPass;
    $this->dbName=$dbName;
    $this->connectToDb();
}[/php]

Thanks,

SACoder

Hi there,

What the error is telling you is that PHP no longer allows you to reference (using =&) when initiating a class. Just remove the “&” symbol and use it like you would assign a variable and it should work. Also, you are not showing all of your code so while this will fix the error issue, I don’t know if it will fix all of your issues.

Hope this helps.

Sponsor our Newsletter | Privacy Policy | Terms of Service