Reputation: 13
I have problem when excecute the exec function in while loop
I want to transfer xml file to server the problem is the transfer to server is success
but the data xml is same at all, the data is still the first xml data
are the exec action is cannot be run in while condition ? or i must clear something before run the next while ?
mysql_connect("someaddress","root","somepass");
mysql_select_db("somedatabase");
$t_data = mysql_query("SELECT * FROM inbox_hmis WHERE ordernumber = '01' AND status = 'false'");
while($data = mysql_fetch_array($t_data)){
$un_id_sms = $data['id_sms'];
echo "$un_id_sms";
$xmlget = "/var/www/sms/basedata/$un_id_sms.xml";
exec("curl -d @$xmlget http://apps.dhis2.org/demo/api/dataValueSets -H Content-Type:application/xml -u admin:password", $output);
$outx = $output[0];
$outx_r = str_replace("'", '"', $outx);
echo "$outx_r | ";
}
$un_ind_sms
is unique id and the name of xml file
$outx_r
is the xml data
Upvotes: 1
Views: 2111
Reputation: 1438
You are not resetting the content of variable $output
before calling exec. E.g.
unset($output); // as recomended in php docs
Before the exec call will fix your problem.
As stated in exec documentation if the array of lines already contains data, then the new result will be appended to it.
Upvotes: 1