PHP MySQLi doesn't recognize login info

2019-01-29 11:44发布

问题:

I can't login to the database using mysqli class.

I get the next error:

Warning: mysql_query(): Access denied for user 'www-data'@'localhost' (using password: NO) 

I have the next code:

$this->mysqlCon = new mysqli($siteConfig['db']['hostname'], $siteConfig['db']['username'], $siteConfig['db']['password'], $siteConfig['db']['database']);

var_dump() of $siteConfig['db'] returns:

array(4) {
  ["hostname"]=>
  string(9) "localhost"
  ["username"]=>
  string(4) "root"
  ["password"]=>
  string(*) "***Censored***"
  ["database"]=>
  string(*) "***Censored***"
}

My VPS is running Debian 6 32bit.

Thanks in advance.

回答1:

Warning: mysql_query()
             ^---------------------- notice something? :)

You seem to be mixing up mysql and mysqli in your code.