PHP错误[而处理这个指令发生了错误]错误、指令、发生了、PHP

2023-09-10 20:08:04 作者:@我绝版了i

我有搜索基于一些过滤器的数据库和回显结果的数量PHP脚本。我要求这个文件与阿贾克斯,才能够显示的结果数的搜索返回用户改变了一些选择之后。

I have a php script that searches a database based on some filters and echoes back the number of results. I request this file with ajax, to be able to display the number of results the search returns right after the user changes some selects.

这只是正常的本地主机上,但它并不在生产服务器上,因为我不知道什么是错的(没有明显的错误)我直接调用PHP脚本,看看是否有任何错误或不。我得到的是<! - SHTML包装 - 500服务器错误 - > [而处理这个指令发生了错误] PHP的包括2个文件,数据库连接信息和一些初始化的东西。我使用相对路径,这两个文件是在正确的位置,具有正确的权限。

This works just fine on a local host, but it doesn't on a production server, and since I had no idea what was wrong (no visible errors) I called the php script directly, to see whether it has any errors or not. what I get is <!-- SHTML Wrapper - 500 Server Error --> [an error occurred while processing this directive] The php includes 2 files, the database connection info, and some initialization stuff. I used relative path, and both files are at the correct location, with correct permissions.

我查了错误日志,既然没有什么在那里。我GOOGLE了这一点,但没有具体的来了,和ATM我不知道如何来解决这个问题。 请指教!

I checked the error log, and since there's nothing in there. I googled this, but nothing concrete came up, and ATM I have no idea how to get around this. Please advise!

推荐答案

第1步:启用PHP错误打印

为了找出错误,使错误为你的PHP。

In order to find out the bug, enable errors for your PHP.

从 http://www.bradino.com/php/error-reporting/:

ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);

如果不工作,编辑php.ini文件(见的http:// PHP .NET /手动/ EN / errorfunc.configuration.php ),并设置:

If that doesn't work, edit php.ini (see http://php.net/manual/en/errorfunc.configuration.php) and set:

display_errors=1

如果你不知道你的php.ini位于用途:

If you don't know where your php.ini is located use:

<?php phpinfo(); ?>

和定位的配置文件(php.ini中)路径的。对于视觉说明,请参阅: http://www.php-scripts.com/20050909/8/

And locate "configuration file (php.ini) path". For visual instructions, see: http://www.php-scripts.com/20050909/8/

第2步:调试你的Apache / Web服务器日志

如果你还是不明白PHP中的任何错误,这个问题必须与Web服务器:

If you still don't get any errors in PHP, the problem has to be with web server:

如果您使用的是Apache,找到的access.log error.log中,看看他们是否包含相关信息到了这个问题。

If you are using Apache, locate access.log and error.log and see if they contain messages related to this issue.

提示:尾-f xxx.log 可让您追踪实时变化日志(用于调试非常有用)

Hint: tail -f xxx.log allows you to track changes in a log in real-time (very useful for debugging).