I am creating some login pages on Linux using PHP and MySql. It worked perfectly before. However, all of a sudden, I start to get the PHP code on a browser instead of the table that was displayed before.I didn't change the code at all and the database and tables are still there, but when I log into MySql with mysql -r root -p, I got an error that is 'ERROR 1045 (28000): Access denied for user 'student'@'localhost'  (using password: YES)'  , so I have to log into MySql with sudo mysql -r root -p.Login page (worked before):$servername = localhost;$username = phpproject;$password = pass;$dbname = ProjectDb;// Create connection    $conn = new mysqli($servername, $username, $password, $dbname);    // Check connection    if ($conn->connect_error) {        die(Connection failed:  . $conn->connect_error);    }Trial login page:   define('DB_SERVER', 'localhost');   define('DB_USERNAME', 'phpproject');   define('DB_PASSWORD', 'pass');   define('DB_DATABASE', 'ProjectDb');   $db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);Does anyone have any idea what is the problem?
Cannot connect to MySql using PHP on Linux
linux;mysql;php
mysql -r root -p will attempt to connect to the schema root as the current user, with a password prompt, using raw output.  This is probably not what you intend to be doing.Try mysql -uphpproject -p ProjectDb.  If that works, something is awry in your PHP configuration; if it does not, you have bad credentials.  The answer is not to just connect as the root user; the answer is to correct your credentials.