PHP curl questions - running multiple times

yesvalid

New Member
I have this code:\[code\]<?php foreach($items as $item) { $site = $item['link']; $id = $item['id']; $newdata = http://stackoverflow.com/questions/3872955/$item['data_a']; $newdata2 = $item['data_b']; $ch = curl_init($site.'updateme.php?id='.$id.'&data1='.$newdata.'&data2='.$newdata2); curl_exec ($ch); // do some checking here curl_close ($ch); }?>\[/code\]Sample input:\[code\]$site = 'http://www.mysite.com/folder1/folder2/';$id = 512522;$newdata = 'http://stackoverflow.com/questions/3872955/Short string here';$newdata = 'http://stackoverflow.com/questions/3872955/Another short string here with numbers';\[/code\]Here the main process of updateme.php\[code\]if (!$id = intval(Tools::getValue('id'))) $this->_errors[] = Tools::displayError('Invalid ID!');else{ $history = new History(); $history->id = $id; $history->changeState($newdata1, intval($id)); $history->id_employee = intval($employee->id_employee); $carrier = new Carrier(intval($info->id_carrier), intval($info->id_lang)); $templateVars = array('{delivery}' => ($history->id_data_state == _READY_TO_SEND AND $info->shipping_number) ? str_replace('@', $info->shipping_number, $carrier->url) : ''); if (!$history->addWithemail(true, $templateVars)) $this->_errors[] = Tools::displayError('an error occurred while changing status or was unable to send e-mail to the employee');}\[/code\]The site will always be changing and each $items will have atleast 20 data inside it so the foreach loop will run atleast 20 times or more depending on the number of data.The target site will update it's database with the passed variables, it will probably pass thru atleast 5 functions before it is saved to the DB so it could probably take some time too.My question is will there be a problem with this approach? Will the script encounter a timeout error while going thru the curl process? How about if the $items data is around 50 or in the hundreds now?Or is there a better way to do this?UPDATES: * Added updateme.php main process code. Additional info: updateme.php will also send an email depending on the variables passed.
  • Right now all of the other site are hosted in the same server.
 
Back
Top