07-03-2008, 07:12 AM
|
#11 (permalink)
|
|
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
|
This part here:
PHP Code:
public function specs($dbn, $user, $pass) { $this->dbn = $dbn; $this->user = $user; $this->pass = $pass; $this->dbtestcon = $dbtestcon; $dbtestcon = mysql_connect($dbn, $user, $pass); if (!$dbtestcon) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; }
Should be written:
PHP Code:
public function specs ($dbn, $user, $pass) { $this->dbn = $dbn; $this->user = $user; $this->pass = $pass;
// You were originally trying to assign an empty variable, $dbtestcon to $this->dbtestcon $this->dbtestcon = mysql_connect($dbn, $user, $pass);
// You need to use $this to assign properties to a global reference inside your class // Any variables that are called within a function directly (such as $dbtestcon as // opposed to $this->dbtestcon) are local to that function and do not exist in the global // scope of a class. if ( ! $this->$dbtestcon) { die('Could not connect: ' . mysql_error()); }
echo 'Connected successfully'; }
-m
|
|
|
|