Mysql возвращает ошибку соединения 500 вместо выполнения функции diePhp

Кемеровские программисты php общаются здесь
Гость
Mysql возвращает ошибку соединения 500 вместо выполнения функции die

Сообщение Гость »


Я разрабатываю приложение и пытаюсь отладить любые ошибки.
Сначала я создал простой сценарий подключения MySql, см. ниже:

Код: Выделить всё

$conn = new mysqli("localhost","root","AwesomePassword", "todo");

if ($conn->connect_error) {
die ("Failed to connect to MySQL: (" . $conn->connect_errno . ") " . $conn->connect_error);
}
Now, I'm trying to debug this code by changing the credentials. In stead of the 'die' function is triggerd, I get "localhost is currently unable to handle this request.
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

Вернуться в «Php»