[PHP-DB] case to comment, please
I have the following example case: 1- More than 1000 record in my MySQL database. 2- I have to submit those record via HTTP GET or POST method. 3- I have to read the confirmation message that will be printed on the remote page showing me that the vars have been inserted in the remote database. 4- of course, I have a limitation of executing time of 30 seconds and i should not modify the php.ini i did the following scenario : ?php function send_rec($var1 , $var2 ,$var3 ){ $handle = fopen(http://anotherwebserver/url2.php?var1=$var1$var2=$var2var3=$var3;, r) ; $data = fread($handle, 11); fclose($handle); if ($data == $var1) return true; else return false; } for ($i=0 ; $iNUM OF RECORDS ; $i++) { send_rec( $var1 , $var2 , $var3 ); } ? 1-the problem is that the 30 second of execution time expired before i can send even 200 records. 2- in case of not connection of the remote page, and i did not get the $var1 printed ($data == $var1) then i have to re submit this record. Regards -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] case to comment, please
Nabil wrote: 1-the problem is that the 30 second of execution time expired before i can send even 200 records. http://php.net/set_time_limit Personally I'd call set_time_limit once for each iteration of the loop with a sensible timeout like 30 seconds. Alternatively you can call it once at the start of the script with a timeout of 0 to let it run as long as it needs to. 2- in case of not connection of the remote page, and i did not get the $var1 printed ($data == $var1) then i have to re submit this record. The for loop doesn't make much sense since $var1/2/3 don't change with each iteration, but assuming $i is used to select the record to send something like this should do the trick... for ($i=0 ; $iNUM_OF_RECORDS ; $i++) { if (!send_rec( $var[$i][0] , $var[$i][1] , $var[$i][2] )) $i--; // Redo this record } I'd suggest you add something to ensure you don't retry the same record forever, but I'll leave that as an exercise for the reader :) -- Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php