douyulv6921 2016-06-25 09:16
浏览 17
已采纳

如何在浏览器中显示大约1000张30 kb的图像?

I am trying to display around 1000 .jpg images of size 30 kb each (in average). Let me show the script first :

<?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>";            
?>

While the number of images is less say around 20, no error occurs and the script works perfectly fine. But as the number exceeds say 200 then "500 Internal Server Error" is coming up. How to cop up with this situation? Please suggest a remedy.

  • 写回答

1条回答 默认 最新

  • donglu1913 2016-06-25 11:02
    关注

    A 500 error in PHP generally means the script crashed. You need to know why it crashed.

    That can sometimes be found in the web server error log or the php error log. You didn't say what platform (linux / apache / php? windows / iis / php? ) you're running on so it's hard to tell you where to look. Use your favorite search engine to ask for php error log location linux apache or whatever. Then look at the end of the error log.

    While you're at it, look for php.ini location linux apache. There's a file called php.ini containing system limits.

    I guess you are running out of time or RAM. PHP generally won't let you arbitrarily increase the time limit in the way you're trying: set_time_limit (9999). The maximum time you can't exceed is the max_execution_time setting in the php.ini file. You may need to change it there.

    Your PHP script may also be running out of memory. You'll need to change the memory_limit setting to fix that.

    In the comments somebody mentioned the security danger of using the mysql_ interface. That person was not kidding. From comments in your code it looks like your site handles university applications. Now, nobody would dream of cracking a site like that. Would they? Would they? Be careful. Don't rely on a large institution's firewall.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改