Я разрабатываю приложение и пытаюсь отладить любые ошибки.
Сначала я создал простой сценарий подключения MySql, см. ниже:
Код: Выделить всё
$conn = new mysqli("localhost","root","AwesomePassword", "todo");
if ($conn->connect_error) {
die ("Failed to connect to MySQL: (" . $conn->connect_errno . ") " . $conn->connect_error);
}
HTTP ERROR 500".

In my log file of Apache2 I get following message: "::1 - - [11/Mar/2024:11:07:16 +0100] "GET /imap/Connection/connect.php HTTP/1.1" 500 185 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
When the credentials are correct, I get the connection and the pages are working correctly. It seems to be a mysql issue instead of php.
My question: How can I ensure that the 'die' function is executed instead of the HTTP ERROR 500?
With kind regards
Источник: https://stackoverflow.com/questions/781 ... e-function