thallasridevi
07-19-2008, 09:20 AM
i want to execute a script for every 10 seconds . and the loop is 10 minutes long.
I written the code like this but i got timeout warning. i have changed the execution time too in .ini file. please tell me what is wrong or give me a sample code for this:
$time = time();
$timeafter10mins = $time+10*60;
$result = mysql_query("select * from tbl_outbox where UniqueID like '%12345%'");
while($time < $timeafter10mins)
{
while($row = mysql_fetch_array($result))
{
$uniqueid = $row['UniqueID'];
$text = $row['message'];
$from = $row['From_Mobile_number'];
$dated = $row['dated'];
}
if($text!="" && stristr($text,$uniqueid))
{
$data = "<?xml version='1.0' ?>
<SMS NO='$from'><SMStext>".$text."</SMStext><SMStime>".$dated."</SMStime></SMS>";
$fh = fopen($uniqueid.'.xml', 'w');
fwrite($fh, $data);
$xmlfile = $uniqueid.'.xml'
?>
<script>window.location.href='<?=$xmlfile?>';</script><?
exit();
}
$time = $time + 10;
sleep($time);
And also i wanted to delete the xml file after 10 mins.
Please give me a solution. Waiting for your response,
Thanks in advance,
Sridevi.
I written the code like this but i got timeout warning. i have changed the execution time too in .ini file. please tell me what is wrong or give me a sample code for this:
$time = time();
$timeafter10mins = $time+10*60;
$result = mysql_query("select * from tbl_outbox where UniqueID like '%12345%'");
while($time < $timeafter10mins)
{
while($row = mysql_fetch_array($result))
{
$uniqueid = $row['UniqueID'];
$text = $row['message'];
$from = $row['From_Mobile_number'];
$dated = $row['dated'];
}
if($text!="" && stristr($text,$uniqueid))
{
$data = "<?xml version='1.0' ?>
<SMS NO='$from'><SMStext>".$text."</SMStext><SMStime>".$dated."</SMStime></SMS>";
$fh = fopen($uniqueid.'.xml', 'w');
fwrite($fh, $data);
$xmlfile = $uniqueid.'.xml'
?>
<script>window.location.href='<?=$xmlfile?>';</script><?
exit();
}
$time = $time + 10;
sleep($time);
And also i wanted to delete the xml file after 10 mins.
Please give me a solution. Waiting for your response,
Thanks in advance,
Sridevi.