This is what I have in my main page:
$foo = new Foo();
$strQry=$foo->Client();
$user_data=mysql_fetch_object($user_res);
echo $user_data->clientid;
This is what I have in my class file:
class Foo
{
function Client()
{
$strQry = "SELECT clientid FROM users";
$user_res = mysql_query($strQry) or die("Unable to select, Error: ".mysql_error());
return $user_res;
}
}
I am not very good at using classes and functions with PHP and so I'm getting this error "Unable to select, Error: Access denied for user 'nobody'@'localhost' (using password: NO)"
Any help would be greatly appreciated!
mysql_*functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.