If I use simple SQL-PHP connection to test if it can connect to DB like:
$link = mysql_connect('localhost', 'user', 'pass');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected';
mysql_close($link);
It works and connects witohut problems, but when I add it to a class it gives me an error Access denied for user 'root'@'localhost'. This is the class code:
class Konektor {
    private $dbhost = "localhost";
    private $dbuser = "user";
    private $dbpass = "pass";
    var $link;
    function testcon() {
        $link = mysql_connect($dbhost, $dbuser, $dbpass);
        if (!$link) {
            die('Could not connect: ' . mysql_error());
        }
        echo 'Connected';
        closedb($link);
    }
    function closedb($link) {
        mysql_close($link);
    }
}
