我试图显示大约1000个大小为30 kb的.jpg图像(平均)。让我先展示一下脚本:
<?php
ini_set('display_errors', 1);
// database connection files
include '../../lib/config.php';
include '../../lib/opendb.php';
set_time_limit (9999); // to increase execution time for large upload database//
// allow access to page
$showandsave = false; // choosen to view and save the images
if(isset($_POST['submit_html'])){
$showandsave = true;
}
$reportdatefrom = $_REQUEST['reportdatefrom'];
$reportdateto = $_REQUEST['reportdateto'];
// Prepare Constant Query for Master List
$qry_const = "select";
$qry_const .= " "."a.photoname";
$qry_const .= " "."from applicants a";
$qry_const .= " "."where a.date_of_admission between '$reportdatefrom' and '$reportdateto'";
$rs = mysql_query($qry_const) or die("Error Fetching List : ".mysql_error());
$gridsize = 10;
$r = 0;
echo "<table>";
while($row = mysql_fetch_assoc($rs)){
++$r;
if($r == 1 || ($r-1)%$gridsize == 0)
echo "<tr>";
echo "<td><img src='".$row['photoname']."' height='100px' width='75px'/></td>";
if($r%$gridsize == 0)
echo "</tr>";
}
echo "</table>";
?>虽然图像的数量较少,比如20张左右,但没有出现错误,而且脚本运行得非常好。但是当这个数字超过200的时候,"500内部服务器错误“就出现了。如何应对这种情况?请建议一种补救办法。
发布于 2016-06-25 11:02:31
PHP中的500错误通常意味着脚本崩溃。你得知道它为什么坠毁。
有时可以在web服务器错误日志或php错误日志中找到。您没有说哪个平台(linux / apache / php )?windows / iis / php?)你在跑所以很难告诉你去哪找。使用你最喜欢的搜索引擎来查询php error log location linux apache或其他内容。然后查看错误日志的末尾。
当你在做的时候,去找php.ini location linux apache。有一个名为php.ini的文件包含系统限制。
我想你的时间和内存都快用完了。PHP通常不会让您以您正在尝试的方式任意增加时间限制:set_time_limit (9999)。您不能超过的最大时间是 file。你可能需要在那里改变它。
您的PHP脚本也可能内存不足。您需要更改 setting来解决这个问题。
在评论中,有人提到了使用mysql_接口的安全危险。那个人不是在开玩笑。从代码中的注释来看,您的站点似乎处理大学应用程序。现在,没有人会梦想破译一个这样的网站。他们会吗?他们会吗?注意。不要依赖大型机构的防火墙。
https://stackoverflow.com/questions/38026868
复制相似问题