执行时间致命错误

时间:2014-04-10 05:37:30

标签: php mysql

我正在使用带有PHP和MYSQL的libcharts并且它工作正常但是当我在我的代码中使用datetime选择器时它会显示

Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\xampp\libchart\libchart\classes\view\text\Text.php on line 91. 

有时会显示图表,大多数时候会出现此错误。

我更改了max-execution-time=100中的php.ini,但仍然无效。请任何人告诉我解决方案。

这是我的代码:

  mysql_connect ($dhost,$uname,$pword) or die (mysql_error());
  mysql_select_db($dbase) or die (mysql_error());

$chart = new VerticalBarChart(580, 600);

$dataSet = new XYDataSet();
//$to = isset($_REQUEST["to"]) ? $_REQUEST["to"] : "";
//$from = isset($_REQUEST["from"]) ? $_REQUEST["from"] : "";

   if(isset($_REQUEST['to'])){ $to = $_REQUEST['to'];
   if(isset($_REQUEST['from'])){ $from = $_REQUEST['from'];    
  //query all records from the database
  $data = mysql_query("SELECT department, COUNT(visitId) AS visitId FROM visit WHERE CAST(VisitDate AS DATE) BETWEEN '$to' AND '$from' GROUP BY department")
or die(mysql_error());


  //execute the query
  $result = mysql_query($data);



  while ($row = mysql_fetch_assoc($data))
    {
        extract($row);
        $dataSet->addPoint(new Point("$department", $visitId));
    }

    //finalize dataset
    $chart->setDataSet($dataSet);


$chart->setTitle("Total patients(Department)");
$chart->render("generated/bb.png"); 
    }}
    ?>
   <?php
    require_once('calendar/classes/tc_calendar.php');

   header ( "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); 
    header ("Pragma: no-cache");
     ?>
     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script language="javascript" src="calendar/calendar.js"></script>
     <link href="calendar/calendar.css" rel="stylesheet" type="text/css">
     </head>

    <body>
    <form id="form1" name="form1" method="post" action="">
    <table border="0" cellspacing="0" cellpadding="2">
    <tr>
   <td>Date :</td>
    <td><?php

  $to_default = "2014-03-31";
  $from_default = "2014-04-07";

  $myCalendar = new tc_calendar("to", true, false);
  $myCalendar->setIcon("calendar/images/iconCalendar.gif");
  $myCalendar->setDate(date('d', strtotime($to_default))
        , date('m', strtotime($to_default))
        , date('Y', strtotime($to_default)));
  $myCalendar->setPath("calendar/");
  $myCalendar->setYearInterval(1999, 2030);
  $myCalendar->setAlignment('left', 'bottom');
  $myCalendar->setDatePair('to', 'from', $from_default);
  $myCalendar->writeScript();     

  $myCalendar = new tc_calendar("from", true, false);
  $myCalendar->setIcon("calendar/images/iconCalendar.gif");
  $myCalendar->setDate(date('d', strtotime($from_default))
       , date('m', strtotime($from_default))
       , date('Y', strtotime($from_default)));
  $myCalendar->setPath("calendar/");
  $myCalendar->setYearInterval(1999, 2030);
  $myCalendar->setAlignment('left', 'bottom');
  $myCalendar->setDatePair('to', 'from', $to_default);
  $myCalendar->writeScript();     
      ?></td></tr>
      </table>
        <input type="submit" name="Submit" value="Submit" />

      </form>
       <img alt="Vertical bars chart" src="generated/bb.png" style="border: 1px solid gray;"/>
        </body>
        </html>

1 个答案:

答案 0 :(得分:-1)

在查询之前使用set_time_limit(50)来增加默认执行时间