Re: [PHP-DB] Auto-update database records

2002-06-12 Thread Tony

I finally got this auto-update script to work, thanks for your so many
replies.

Tony S. Wu 

Jason Wong at [EMAIL PROTECTED] wrote:

 On Saturday 08 June 2002 21:34, Tony wrote:
 I do appreciate your reply.
 Yes, I've tried to track down the problem.
 I comment-out the fopen() function and use echo to display the URL.
 And it displays fine, so I did get the record from MySQL.
 Then when I put the fopen() back, same problem appears.
 
 You did check that $buffer contains what you expect for each iteration of
 $final_result?
 
 I think it's probably because I have too much data to update at once, over
 a hundred maybe?
 Then it causes the PHP to timeout this script hence the error.
 
 You can use set_time_limit(3000) inside a loop (probably the foreach) as each
 time it is used it will reset the max execution time to 3000secs.
 
 As I said before, see what's happening to the value of $counter. Or simplify
 that loop with a regular expression.





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




[PHP-DB] Auto-update database records

2002-06-08 Thread Tony

Here is my code.
If you see some variables not defined, assume it is:

?
require_once(fn_web.php);
require_once(fn_db.php);

set_time_limit(3000);

set_header(Auto-Update);

$final_result = get_records($_POST[key]);
// getting the records from database

foreach ($final_result as $final)
{
$fp = @ fopen($final[url], r);

if (!$fp)
{
echo font color = \#FF\Error: URL ba href =
\.$final[url].\
target = \blank\.$final[url]./a/b does not
exist./fontbr;
}
else
{
// get rid of html tags
while (!feof($fp))
{
// do something to get rid of html tags
}

fclose($fp);

// find the $ sign
while ($counter  $i)
{
if ($buffer[$counter] == '$')
{
$counter++;
   
while (doubleval($buffer[$counter]) || $buffer[$counter]
== .)
{
$price .= $buffer[$counter];
$counter++;
// $price_array_holder++;
}
//$price_array_holder = 0;
$price_count++;
}
else
$counter++;
}

if ($price_count  1)
// more than one price found
{
echo font color = \#FF\Error: Multiple price found
for partnum b
a href = \.$final[url].\ target =
\blank\.$final[partnum].
/a/b./fontbr;
}
else if ($price_count == 0)
// no price has been found
{
echo font color = \#FF\Error: No price found for
partnum b
a href = \.$final[url].\ target =
\blank\.$final[partnum].
/a./fontbr;
}
else if ($price == $final[price])
{
echo font color = \#00A5C6\No change has made for
partnum b
a href = \.$final[url].\ target = \blank\.
$final[partnum]./a/b, price
remains.$price./fontbr;
}
else
{
if (process_change($final[partnum], $price, $vendor,
$final[url]))
{
echo font color = \#218429\Update price to
.$price. for
partnum ba href = \.$final[url].\ target =
\blank\.
$final[partnum]./a/b./fontbr;
}
}

flush();

}
}

set_footer();
?

Tony S. Wu
[EMAIL PROTECTED]


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




Re: [PHP-DB] Auto-update database records

2002-06-08 Thread Jason Wong

On Saturday 08 June 2002 20:35, Tony wrote:
 Here is my code.
 If you see some variables not defined, assume it is:

Hmm, is there a problem with your code? If so could you state what the problem 
is?

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
Any man who hates dogs and babies can't be all bad.
-- Leo Rosten, on W.C. Fields
*/


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




Re: [PHP-DB] Auto-update database records

2002-06-08 Thread Tony

You are being picky on me, huh?
I stated my problem 3 emails ago, browser gives me error attempt to load
MyPage's URL failed.
Could be because of execution timeout.
I tried to set the time longer with no luck.
If I put the flush() after each data, I get the first output only.
But I need to update the database very often, and I don't want to do it by
hands..

Tony S. Wu
[EMAIL PROTECTED]


 On Saturday 08 June 2002 20:35, Tony wrote:
 Here is my code.
 If you see some variables not defined, assume it is:
 
 Hmm, is there a problem with your code? If so could you state what the problem
 is?




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




Re: [PHP-DB] Auto-update database records

2002-06-08 Thread Jason Wong

On Saturday 08 June 2002 20:52, Tony wrote:
 You are being picky on me, huh?

I'm sorry if you feel offended ...

 I stated my problem 3 emails ago, 

... but I delete mail from this list as soon as I've finished with them. As 
you have started a new thread one would naturally assume this is a new 
problem. Please don't expect people to remember dead threads.

 browser gives me error attempt to load
 MyPage's URL failed.

 Could be because of execution timeout.
 I tried to set the time longer with no luck.
 If I put the flush() after each data, I get the first output only.
 But I need to update the database very often, and I don't want to do it by
 hands..

Have you tried tracking down where it is that the script fails? 

Either use echo() or error_log() at various points in the script to monitor 
what the program is doing. For example before starting the while-loops 
echo(Entering while loop) and inside the while-loop echo($counter), and 
when the loop terminates echo someting to that effect. This should at least 
tell you whether you have any infinite loops.

Another thing you can do is simplify the check for the prices. Your present 
method seems to be veru long-winded. I think a single preg_match() could 
replace the while ($counter  $i) loop.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
YOU PICKED KARL MALDEN'S NOSE!!
*/


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




Re: [PHP-DB] Auto-update database records

2002-06-08 Thread Tony

I do appreciate your reply.
Yes, I've tried to track down the problem.
I comment-out the fopen() function and use echo to display the URL.
And it displays fine, so I did get the record from MySQL.
Then when I put the fopen() back, same problem appears.
I think it's probably because I have too much data to update at once, over a
hundred maybe?
Then it causes the PHP to timeout this script hence the error.
If I can't solve this on PHP, I'll have to find an alternative way to do
this...

Tony S. Wu
[EMAIL PROTECTED]


 On Saturday 08 June 2002 20:52, Tony wrote:
 You are being picky on me, huh?
 
 I'm sorry if you feel offended ...
 
 I stated my problem 3 emails ago,
 
 ... but I delete mail from this list as soon as I've finished with them. As
 you have started a new thread one would naturally assume this is a new
 problem. Please don't expect people to remember dead threads.
 
 browser gives me error attempt to load
 MyPage's URL failed.
 
 Could be because of execution timeout.
 I tried to set the time longer with no luck.
 If I put the flush() after each data, I get the first output only.
 But I need to update the database very often, and I don't want to do it by
 hands..
 
 Have you tried tracking down where it is that the script fails?
 
 Either use echo() or error_log() at various points in the script to monitor
 what the program is doing. For example before starting the while-loops
 echo(Entering while loop) and inside the while-loop echo($counter), and
 when the loop terminates echo someting to that effect. This should at least
 tell you whether you have any infinite loops.
 
 Another thing you can do is simplify the check for the prices. Your present
 method seems to be veru long-winded. I think a single preg_match() could
 replace the while ($counter  $i) loop.





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




Re: [PHP-DB] Auto-update database records

2002-06-08 Thread Jason Wong

On Saturday 08 June 2002 21:34, Tony wrote:
 I do appreciate your reply.
 Yes, I've tried to track down the problem.
 I comment-out the fopen() function and use echo to display the URL.
 And it displays fine, so I did get the record from MySQL.
 Then when I put the fopen() back, same problem appears.

You did check that $buffer contains what you expect for each iteration of 
$final_result?

 I think it's probably because I have too much data to update at once, over
 a hundred maybe?
 Then it causes the PHP to timeout this script hence the error.

You can use set_time_limit(3000) inside a loop (probably the foreach) as each 
time it is used it will reset the max execution time to 3000secs.

As I said before, see what's happening to the value of $counter. Or simplify 
that loop with a regular expression.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
In Oz, never say krizzle kroo to a Woozy.
*/


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