Using this:
$db = mysqli_connect
(
$db_host,
$db_user,
$db_pwd
) or die ("FATAL ! : The server ".$db_host." is not responding to ".$db_user."!");
how to get the $db value into this class (from include "class.php") - without errors ;-)
class User
{
public $db;
public $id;
public function getUser()
{
if($this->id)
{
$sql = "
SELECT
users.*
FROM
users
WHERE
users.u_id='".$this->id."'
";
$res = mysqli_query($db, $sql) or die(mysqli_error($db));
$user_row = mysqli_fetch_object($db, $res);
return $user_row;
}
else
{
return false;
}
}
} // end class User
All I get is - well, nothing. Exept my main page loads empty... If I stop using the class, all is well (exept no data for the user is shown ;-))
singletonorfactorypattern and call it statically.