Warning: mysqli_connect(): (HY000/2002): No connection could be made because the target machine actively refused it. in E:\xampp\htdocs\ss\docs\regional.php on line 15
The connection to the database could not be established.
Is this a serious error or can easily be ignored? The error message 'The connection to the database could not be established.' is expected to pop but not the warning text. How do I remove it in that case. Below is the code I’ve used.
$db = mysqli_connect('localhost', 'root', '', 'regional_data');
if(mysqli_connect_errno()) {die('The connection to the database could not be established.');}
EDIT: I have stopped SQL in the development area to test this and the message occurs at that time.
In your development environment it is completely legal to have the settions of display_errors on. This is the most easy way to see if things go wrong.
In productive environment you wouldn’t set this to on, because the user usually does not need to know if PHP things go wrong – he even should not, because these messages might contain valuable information for attackers. That should only be communicated through dedicated error messages like inside your
die()So the warning in your output will go away if you disable display_errors, but you really want to have this warning in your logfile. Suppressing the warning with an
@is not reccommended!