In the main directory of the website in the index.php file, On the line 11 I have this line:
require_once('../db.php');
The db.php file contains the information for connecting to MySQL server and database which is under the root directory one level above the public_html directory.
I have disabled php error report so that the user won't see the errors and by doing that it stores the errors in a file called error_log.
Sometimes I see this error in that file for an unknown reason:
[24-May-2022 00:18:28 UTC] PHP Fatal error: Uncaught mysqli_sql_exception: No such file or directory in /home/username123/db.php:17
Stack trace:
#0 /home/username123/db.php(17): mysqli_connect('localhost', 'username123_dbname...', 'password', 'db_username', 1234)
#1 /home/username123/public_html/index.php(11): require_once('/home/username123/...')
#2 {main}
thrown in /home/username123/db.php on line 17
And the line 17 in the db.php is this:
$con = mysqli_connect(HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_NAME, 1234) or die ("error");
I don't know why this happens. That db.php file is always there and visiting the home page doesn't have any problems.
But my question is this:
In the error log it shows the username and password and database name etc, How can I prevent that?