Apache error log gives 'access denied'



The error:
[Tue Aug 21 09:19:57.729511 2018] [:error] [pid 1260] [client ::1:38799] PHP Warning: mysql_set_charset(): Access denied for user ‘’@‘localhost’ (using password: NO) in UserHelper.class.php on line 163

Could anyone help, how I’ll find where the mysql username and pw are declared? The code of the page is unknown for me…

  1. You are using removed code.
  2. How can you not know where the credentials are? Did you not write the code?


No, I didn’t write it. I’m just about to improve it. It’s maybe impossible, because I have no idea, how to use PEAR and DB and such.


The error is because you are calling a mysql_ statement without having a mysql_ connection. In this case, php attempts to make a mysql_ connection using its default connection settings.

You should not be using any mysql_ statements since they are obsolete and have been removed from the latest php version.


mysql_set_charset should be working, because I’ve installed php5-mysqlnd. It should replace MySQLi, according to these:



The mysqlnd driver has nothing to do with this. It’s the driver that gets used by whichever php database extension (mysql, mysqli, PDO) you are using.

The error is because you don’t have a connection using the mysql extension, which you shouldn’t be using at all. You should be using the php PDO extension (forget about the mysqli extension, it is overly complicated and inconsistent.)

If you want help with converting old code, you will need to post the code.


This is line 163 from UserHelper.class.php:

$db = DB::connect(DSN);mysql_set_charset(‘utf8’);$db->query(“SET NAMES ‘utf8’”);

I’m unfortunately not allowed to reveal the code too much.


Ok and thanks! Now I’ve found the configuration file which needed the root pw. Doesn’t give error more about connecting to mysql. But still gives this:

[Wed Aug 22 09:40:17.176036 2018] [:error] [pid 1255] [client ::1:37863] PHP Fatal error: Call to undefined method DB_Error::query() in /var/www/html/blah/blah/blah/blah/UserHelper.class.php on line 163

I think that maybe it’s about the DB -version…?


Check the class for that method.

Your code still needs a 15 year update.