note 123841 deleted from security.database.connection by cmb
| From: | cmb@php.net | Date: | Sun, 12 May 2019 10:49:17 +0000 |
| Subject: | note 123841 deleted from security.database.connection by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211007@lists.php.net to get a copy of this message | ||
Note Submitter: jude dot uk dot gabriel at gmail dot com
----
<?php
function connect_DB()
{
$servername = htmlspecialchars("localhost");
$username = htmlspecialchars("root");
$password = htmlspecialchars("");
$database = htmlspecialchars("lab2019");
@ $conn = mysqli_connect($servername,$username,$password,$database);
if(!$conn && DEBUG == 1)
{
die('Connection failure : </br>(' . mysqli_connect_errno() . ') ' .
mysqli_connect_error()); //Return an error description from the last connection error, if any when
error reporting is ON
}
elseif(!$conn && DEBUG == 0)
{
//log the error and display a message to the user when Debug is off
if(mysqli_connect_error())
{
$logMessage = 'MySQL ERROR:'.mysqli_connect_error();
//log error to file
error_log($logMessage,0);
exit('Website Under Maintenance!!! </br> Try Again Later or email support@fishing.com
if urgent matters');
}
}
else
{
//echo "Database Connected.";
return $conn;
}
}