MySQL Connection Error (Access denied for user 'www-data'@'localhost' (using password: NO).)
<p><em>Note: I'm still learning PHP/MySQL apologies if this is obvious. I've researched across a few sites and have not found a solution</em></p>

<p>The Problem: I am receiving a connection error when attempting to access my database for a registration/login system. (Access denied for user 'www-data'@'localhost' (using password: NO).).</p>

<p>The error suggests that my defined values are being ignored (for whatever reason?)</p>

<p>My Code:</p>

<pre><code>&lt;?php
//error reporting
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
//DBinformation
define('hostname',"127.0.0.1");
define('username',"secure_logger");
define('password',"**********"); //Censored the pass
define('DBname',"rota_site");


$con = new mysqli(hostname, username, password) or die('localhost connection problem'.mysql_error());
mysqli_select_db($con, DBname);
</code></pre>

<p>I've managed to work around the issue by using a different connection method so I believe the issue is with new mysqli().</p>

<p>While I am still learning PHP/MySQL I've found many tutorials which seem to be connecting to the database using this method and I'd like to return back to it. My coursework rewards marks for using object-oriented methods of programming and as far as I know the above method of connection is object-oriented.</p>

<p>Addition details: I am using my Raspberry Pi 3 (Raspbian) to host the web server and database. PHPMyAdmin does not have an account known as 'www-data'. I am using Apache.</p>

<p>Does anyone know why I am receiving the error while using this type of connection and further know a solution?</p>

<p><em>I've used other methods of entering the values into the parentheses and it still returns the same error message.</em></p>