Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 31st, 2004, 03:08 AM
Authorized User
 
Join Date: Jan 2004
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default connection timeout

this is my code:
[code]
<?php
ob_start();
include("../inc/config.php");

function query($query, $link, $line, $file)
{
    $result = mysql_query($query);
      if (empty($result) && ini_get('display_errors') == 1)
        {
            echo mysql_error().": ";
            echo mysql_errno()."<br />\n";
            echo $query."<br />\n";
            echo "@ $line in $file\n";
        }
    return $result;
}

$Tdate = getdate();
$datToday = strftime("%m/%d/%Y");
$NowYear=strftime($datToday,"%Y");
$mulaServis=$_POST["mulaServis"];
$tamatServis=$_POST["tamatServis"];
$start=date("YmdHis",strtotime($mulaServis));
$end=date("YmdHis",strtotime($tamatServis));
?>





<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

</HEAD>

<BODY>

<form name="myform" action="outSnapKomponen1.php">

<table width="100%" border="1" bgcolor="#666666" bordercolor="#333333" align="center">
  <tr>
    <td align="center">
      <b>
      BILANGAN KEROSAKAN BERDASARKAN KOMPONEN
      </b>
    </td>
  </tr>
</table>
<br>
<?php
//****************PANGGIL SEMUA PEKERJA***********

$viewall=query("Select * from repairbreakdown inner join komponen on repairbreakdown.komponen = komponen.id WHERE repairbreakdown.waktuTamat BETWEEN '$start' AND '$end'", $link, __LINE__, __FILE__);
$senarai=mysql_fetch_array($viewall);
?>


<?php
if (empty($senarai))
{
?>

<br>
<table width="100%" border="0"align="center">
  <tr>
    <td align="center">
      <b>
      Maaf ! Tiada maklumat di dalam pangkalan data
      </b>
    </td>
  </tr>
</table>
<P><BR>

<CENTER>
  <A HREF="snapMenu.php">
  <STRONG>
    KEMBALI
  </STRONG>
  </A>
</CENTER>

<?php
}
  else
{


$bil=1;
?>


<?php
  while($senarai)
  {
?>


<?php
//----------------------------------------------------

// CAPAI DAN TABLE SEMENTARA

// NAMA TABLE : TEMPLOKASI

//----------------------------------------------------

$viewCheck=query("SELECT * FROM tempkomponen WHERE komponen = '{$senarai["alat"]}' ORDER BY komponen", $link, __LINE__, __FILE__);
$periksa=mysql_fetch_array($viewCheck);

    if (empty($periksa))
    {


//----------------------------------------------------------------

//SEKIRANYA TIADA LOKASI YANG SAMA DALAM PANGKALAN DATA TEMPLOKASI

//----------------------------------------------------------------


      $jumlah=1;


      $SQLinsert=query("INSERT INTO tempkomponen(komponen,jumlah) VALUES('{$senarai["alat"]}','$jumlah')", $link, __LINE__, __FILE__);
    }
      else
    {


//----------------------------------------------------------------

//SEKIRANYA ADA LOKASI YANG SAMA DALAM PANGKALAN DATA TEMPLOKASI

//----------------------------------------------------------------


      $nilai=$periksa["jumlah"]+1;

      $SQLupd=query("UPDATE tempkomponen SET jumlah = '$nilai' WHERE komponen ='{$senarai["alat"]}'", $link, __LINE__, __FILE__);



    }
    $bil=$bil+1;
  }
?>

</table>
<P><BR>


<?php
//----------------------------------------------------

// CAPAI DAN TABLE SEMENTARA

// NAMA TABLE : TEMPLOKASI

//----------------------------------------------------

$viewCheck=query("SELECT * FROM tempKomponen order by komponen", $link, __LINE__, __FILE__);
$periksa1=mysql_fetch_row($viewCheck);
?>
<?php
  $ParameterCounter=1;
  while($periksa1)
          $alat[]=$periksa1[0];
        $jum[]=$periksa1[1];
  {
?>
<?php
    session_start();
    $_SESSION["firstquarter"] = $alat;
    $_SESSION["firstquarter2"] = $jum;
    $ParameterCounter=$ParameterCounter+1;

  }
?>
<center><IMG SRC="outSnapkomponen1.php"></center>

<BR><BR>
<CENTER>
 <strong>
   Anda dikehendaki menekan butang delete terlebih dahulu sekiranya anda hendak melihat keputusan yang tepat pada masa yang akan datang......
 </strong></strong>
 <br><br><br>
 <input style="BACKGROUND-COLOR: #cccccc; BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; COLOR: #333333; FONT-FAMILY: Verdana; FONT-SIZE: 7pt" type="submit" value="DELETE" name="submit">

</center>

<?php
}
?>
</form>
</BODY>
</HTML>
[code]

but..it gives me this error:
Fatal error: Maximum execution time of 30 seconds exceeded in g:\programming\phpdev\www\mmis\analysis\outsnapkom ponen.php on line 7

the line 7 is:
Code:
$result = mysql_query($query);
 
Old February 2nd, 2004, 04:48 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

One of the queries you're running is taking too long.

Figure out which one it is and fix the timing problem.

The simplest way to figure out which one it is is to echo it out to the user before running it. Make sure to remove this code after you're done fixing the problem.


function query($query, $link, $line, $file)
{
    echo "About to run query from $file:$line\n";

    $result = mysql_query($query);
    ...


Take care,

Nik
http://www.bigaction.org/





Similar Threads
Thread Thread Starter Forum Replies Last Post
timeout badboy1 ASP.NET 3.5 Basics 5 August 3rd, 2008 04:36 AM
Timeout when connection to SQL Server in WiFi LAN smp4774 SQL Server 2000 1 June 29th, 2007 07:15 AM
Connection pooling and Timeout Raghavendra_Mudugal SQL Server 2000 2 May 24th, 2006 01:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.