Ok, I posted an example in the body of this for your time out limits but here it is again...

At the end of each of your SQL statements for UPDATE or INSERT simply add ...LIMIT 2000";
That should limit the updating or inserting of database records until the page is refreshed to add more...
HTH
Jas



Haseeb Iqbal wrote:
how can i do that?
btw the script runs on a local machine but updates the records on a
webserver i mean live server. this is also a factor for the timeout. the
script was running smoothly for 24000 recods before but now it suddenly
timeout after 800records. i dont know what is heppening

Haseeb
----- Original Message ----- From: "Jas" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, December 19, 2003 3:16 AM
Subject: [PHP] Re: Script timeout Problem




Have you tried setting a limit on your MySQL insert and update
statements to limit the amount trying to be processed?

Haseeb Iqbal wrote:

hi,
i need to update a mysql table with a dbf file, the dbf file contains

more then 160000 records. i knew that the script will not be able to update 160000 records in 1 go so i am refreshing the page after speacific no of records. but still the same problem. the script timeout.i tried changing the timeout limit to 300 secs but to noavail. i am pasting the code here.plz take a look may by you can tell me what i am doing wrong


<? define("strPath","./");

define("_MySqlEnable",TRUE);

set_time_limit(0);

require_once(strPath."paths.php");

$strDBName=strPath."uploads/".Date("d-m-Y")."-products.dbf";

$DBPointer=dbase_open($strDBName,0) or die("Cannot open file for

reading");


$nNoOfRecs=dbase_numrecords($DBPointer);

$nLoopBreak=1500;

$nConn=GetCon();

if (empty($nLoopStart)) { $nLoopStart=1; }

if ($nNoOfRecs > $nLoopBreak)
 {
  $nLoopTill=$nLoopStart + $nLoopBreak;
  $nFinal=FALSE;
 }
else
 {
  $nLoopTill=$nLoopBreak;
  $nFinal=TRUE;
 }

for ($nCount=$nLoopStart;$nCount<=$nLoopTill;$nCount++)
 {
  $arrData=dbase_get_record($DBPointer,$nCount);

  $GRP=CheckString($arrData[0]);
  $CAT=CheckString($arrData[1]);
  $SUB=CheckString($arrData[2]);
  $VEND_CODE=CheckString($arrData[3]);
  $MANU_PART=CheckString($arrData[4]);
  $PART_NUM=CheckString($arrData[5]);
  $DESCR=CheckString($arrData[6]);
  $COST=CheckString($arrData[7]);
  $RETAIL=CheckString($arrData[8]);
  $QTY=CheckString($arrData[9]);
  $LIST_PRICE=CheckString($arrData[10]);
  $EFF_DATE=CheckString($arrData[11]);
  $TECH_FAX=CheckString($arrData[12]);
  $STATUS=CheckString($arrData[13]);
  $UPC=CheckString($arrData[14]);

$strQuery="SELECT * FROM products WHERE grp='".$GRP."' AND

cat='".$CAT."' AND sub='".$SUB."' AND vend_code='".$VEND_CODE."' AND manu_part='".$MANU_PART."' AND part_num='".$PART_NUM."'";

$nConn->doQuery($strQuery);

  if ($nConn->cntResult()==0)
   $strQuery="INSERT INTO

products(products.grp,products.cat,products.sub,products.vend_code,products. manu_part,products.part_num,products.desc,products.cost,products.retail,prod ucts.qty,products.list_price,products.eff_date,products.tech_fax,products.st atus,products.upc) VALUES('".$GRP."','".$CAT."','".$SUB."','".$VEND_CODE."','".$MANU_PART."','" $PART_NUM."','".$DESCR."','".$COST."','".$RETAIL."','".$QTY."','".$LIST_PRI CE."','".$EFF_DATE."','".$TECH_FAX."','".$STATUS."','".$UPC."')";

$strQuery="INSERT INTO


products(products.grp,products.cat,products.sub,products.vend_code,products. manu_part,products.part_num,products.desc,products.cost,products.retail,prod ucts.qty,products.list_price,products.eff_date,products.tech_fax,products.st atus,products.upc)

VALUES('".$GRP."','".$CAT."','".$SUB."','".$VEND_CODE."','".$MANU_PART."','"
$PART_NUM."','".$DESCR."','".$COST."','".$RETAIL."','".$QTY."','".$LIST_PRI
CE."','".$EFF_DATE."','".$TECH_FAX."','".$STATUS."','".$UPC."'

LIMIT 200)";

  else
   $strQuery="UPDATE products SET

products.part_num='$PART_NUM',products.desc='$DESCR',COST='$COST',retail='$R ETAIL',qty='$QTY',list_price='$LIST_PRICE',eff_date='$EFF_DATE',tech_fax='$T ECH_FAX',status='$STATUS',upc='$UPC' WHERE grp='".$GRP."' AND cat='".$CAT."' AND sub='".$SUB."' AND vend_code='".$VEND_CODE."' AND manu_part='".$MANU_PART."' AND part_num='".$PART_NUM."'";

$strQuery="UPDATE products SET


products.part_num='$PART_NUM',products.desc='$DESCR',COST='$COST',retail='$R ETAIL',qty='$QTY',list_price='$LIST_PRICE',eff_date='$EFF_DATE',tech_fax='$T ECH_FAX',status='$STATUS',upc='$UPC'

WHERE grp='".$GRP."' AND cat='".$CAT."' AND sub='".$SUB."' AND
vend_code='".$VEND_CODE."' AND manu_part='".$MANU_PART."' AND
part_num='".$PART_NUM."'LIMIT 200";

  //echo "<br>nCOunt - > $nCount -----".$strQuery;
  $nConn->doQuery($strQuery);
 }
$nCount++;
$nLoopStart=$nCount;
if ($nFinal==FALSE)
 {
   //1500 records updated so refresh the page
?>
<meta http-equiv="Refresh" content="2;

URL=mypage.php?nLoopStart=<?=$nLoopStart;?>">


<?
 }
else
 {
   // all records updated so redirst to calling page.
?>
<meta http-equiv="Refresh" content="2; URL=main.php?nStatus=1">
<?
 }
?>

Haseeb

That might help out with the timeouts too. Jas

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to