Link to home
Start Free TrialLog in
Avatar of wardjame
wardjame

asked on

Passed by reference notices in legacy php code

I have inherited some legacy code that is throwing some php notices which I would like to fix.  Here is the current notice:
PHP Notice:  Only variable references should be returned by reference in \wwwroot\classes\model\DatabasePeer.php on line 40

Open in new window


and here is the code in DatabasePeer.php around line 40 (line 40 is line 2 here):
public static function &connect($host,$user,$pass) {        			
        		return @mssql_connect($host, $user, $pass);
        		return 1;
        }

Open in new window


This function is called with the following code:
$conn = DatabasePeer::connect($CONFIG_DATABASE_HOST, $CONFIG_DATABASE_USERNAME, $CONFIG_DATABASE_PASSWORD);
try{
	$sqldb = DatabasePeer::select_db($CONFIG_DATABASE_NAME, $conn);
}catch(Exception $e){
	die("Couldn't open database $CONFIG_DATABASE_NAME".$e);
	exit();
}

Open in new window


Any thoughts how I can change this code to prevent the notice?
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial