You have declared your function
db()
as
static
. Static functions have no access to member variables or non-static member functions. So the variable
$con
used within the static function is not the class member variable but a local variable and the class member variable stays unitialised.
Solution: Remove the
static
keyword.
[EDIT]
You should also declare the variables in your
db()
function at function level scope and not within conditional scope and check if the connection was successful:
$host = 'alltoitskin.db.7649825.hostedresource.com';
$username = 'alltoitskin';
$pass = 'Skinlogica123';
$db ='alltoitskin';
if($_SERVER['HTTP_HOST'] == 'localhost'){
$host = 'localhost';
$username = 'root';
$pass = '';
$db = 'alltoitskin';
}
[/EDIT]