php PHP错误,没有收到数据

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7128134/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:04:51  来源:igfitidea点击:

PHP error, no data received

php

提问by mowwwalker

I keep getting this error:

我不断收到此错误:

No data received
Unable to load the webpage because the server sent no data.
Here are some suggestions:
Reload this webpage later.
Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.

I know it's part of my script, but I don't know which part. It divides certain text into a few different files, and those files are being created, but it's also supposed to zip them, but it's not getting to that part, so I have a vague idea of the general area the problem is occurring. I know this entire question is lacking detail, but I'm hoping that someone who has more experience with PHP and who may have seen the error before would be able to tell me what's happening.

我知道这是我脚本的一部分,但我不知道是哪一部分。它将某些文本分成几个不同的文件,这些文件正在被创建,但它也应该压缩它们,但它没有到达那个部分,所以我对发生问题的一般区域有一个模糊的概念。我知道整个问题都缺乏细节,但我希望对 PHP 有更多经验并且之前可能见过错误的人能够告诉我发生了什么。

http://gyazo.com/12ba55613011a115bb7507040f4d3ddf

http://gyazo.com/12ba55613011a115bb7507040f4d3ddf

EDIT: It works on Firefox... How can it be different between browsers if it's server-side script?

编辑:它适用于 Firefox ......如果它是服务器端脚本,它在浏览器之间有什么不同?

采纳答案by AlienWebguy

回答by Jtek Grafix

Restart apache and mysql

重启apache和mysql

service httpd restart

service mysqld restart

服务 httpd 重启

服务 mysqld 重启

Hopefully this answer helps someone.

希望这个答案对某人有所帮助。

回答by Pere

I don't know if you've already solved this, if it's a different problem causing the same symptoms or whatever, but yesterday I noticed this same error on my development machine, running Apache+PHP+MySQL under Linux, when accessing my local phpMyAdmin:

我不知道你是否已经解决了这个问题,如果它是一个不同的问题导致相同的症状或其他什么,但昨天我在我的开发机器上注意到同样的错误,在 Linux 下运行 Apache+PHP+MySQL,当访问我的本地phpMyAdmin:

http://localhost/phpMyAdmin

http://localhost/phpMyAdmin

It was running fine until that day, and I realized that by the same time I changed some settings related to sessions in my php.ini.

直到那天它都运行良好,我意识到在同一时间我更改了一些与 php.ini 中的会话相关的设置。

The problem was caused by having session.save_handler set to user instead of files. So I switched back to

该问题是由 session.save_handler 设置为用户而不是文件引起的。所以我切换回

session.save_handler = files

and voilà... everything is working fine again.

瞧……一切又正常了。

Also be sure to have set the proper session.save_path. In my case, and probably in most Linux systems,

还要确保设置了正确的 session.save_path。就我而言,可能在大多数 Linux 系统中,

session.save_path = "/tmp"

Be sure to set the proper permissions to that directory, too. Mine is chmod'ed to 777.

一定要为该目录​​设置适当的权限。我的已修改为 777。

回答by Cameron Hurd

A little late to the draw here, but I received this error while working on a local copy of a php project (on Chrome), and although Firefox loaded some parts of the pages, it was still throwing similar errors.

在这里抽奖有点晚,但是我在处理 php 项目的本地副本(在 Chrome 上)时收到了这个错误,虽然 Firefox 加载了页面的某些部分,但它仍然抛出类似的错误。

The really weird part was that if I commented out includesor a few functions it would load partially.

真正奇怪的部分是,如果我注释掉includes或一些功能,它会部分加载。

I got around it by restarting the local server. I was using MAMP. You can tell for sure that this is the issue if you're running MAMP by going to the home page - it'll likely throw the same error.

我通过重新启动本地服务器来解决它。我正在使用 MAMP。如果您通过转到主页运行 MAMP,您可以确定这是问题所在 - 它可能会引发相同的错误。

回答by eightyfive

tail -f /opt/local/apache2/logs/error_log

(or wherever is your apache2 install..)

(或者你的 apache2 安装在哪里..)

... Will likely help you to spot where the problem lies in your PHP script. At least it did for me when facing the same problem (No data received, whatever the browser).

... 可能会帮助您找出 PHP 脚本中的问题所在。至少当我面临同样的问题时它对我有用(No data received无论浏览器如何)。

回答by Robert Reynolds

I was getting this issue intermittently in Chrome. For me, reloading the page would get a successful (non-empty) response, but it would sometimes take up to 3 or 4 reloads of the page. To handle this, I added the $.when(), .done(), and .fail()jQuery functions to my AJAX request. If the request fell into the .fail()function, I ran the location.reload();js command to get the page to reload. Otherwise, I called a function that did the rest of my page loading in the .done()function.

我在 Chrome 中间歇性地遇到这个问题。对我来说,重新加载页面会获得成功(非空)响应,但有时需要重新加载 3 或 4 次页面。为了解决这个问题,我加入了$.when().done().fail()jQuery的功能,我的AJAX请求。如果请求落入.fail()函数中,我运行location.reload();js 命令来重新加载页面。否则,我会调用一个函数,该.done()函数会在该函数中加载页面的其余部分。

This has the potential to create an infinite loop with the page never receiving a successful AJAX response and continuing to reload forever. So only try out this method if this issue is intermittent. If you are unable to get a successful AJAX response at all, then this method will not work for you.

这有可能创建一个无限循环,页面永远不会收到成功的 AJAX 响应并继续永远重新加载。因此,如果此问题是间歇性的,请仅尝试使用此方法。如果您根本无法获得成功的 AJAX 响应,则此方法对您不起作用。