gpt4 book ai didi

php - 获取 HTTP 错误 500.0

转载 作者:太空宇宙 更新时间:2023-11-03 10:25:02 24 4
gpt4 key购买 nike

我的系统是 Windows XP SP2,我的服务器是 Microsoft Webmatrix。 PHP 运行良好,但是当我尝试添加数据库连接时,它给出了 http 错误 500.0。报错的代码段

$db = new MySQLi('localhost', 'my_login', 'my_pass', 'db_name');
if ($db->connect_errno()) {
printf("Connect failed: %s\n", $db->connect_error());
exit();
}

当我删除它时,页面加载正常。我该如何解决?

最佳答案

mysqli::connect_errnomysqli::correct_error are properties, not functions :

$db = new MySQLi('localhost', 'my_login', 'my_pass', 'db_name');
if ($db->connect_errno) {
printf("Connect failed: %s\n", $db->connect_error);
exit();
}

您的 PHP 将因此产生错误,并且您关闭了 display_errors,因此它只是被丢弃到服务器日志中,并向用户显示一般的 500 错误。


您还应该注意文档中的说明:

The mysqli->connect_error property only works properly as of PHP versions 5.2.9 and 5.3.0.

您使用的 PHP 版本是 5.2.9 还是 5.3.0 或更高版本?


您必须找到您的服务器日志以便将来进行故障诊断。

根据维基百科,Microsoft WebMatrix is a software bundle which uses IIS Express for webserver functionality .查找 IIS Express 存储其日志的位置会将我们带到 this Q&A ;在您的用户目录(或系统管理员帐户的目录)中查找名为“IISExpress”的目录。

关于php - 获取 HTTP 错误 500.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6992943/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com