I'm trying to get an xml file from an ftp and then insert select data into mysql db. I'm shooting in the dark but from googling this is what i've tried so far:
$curl = curl_init();
$file = fopen("import.xml", 'w');
curl_setopt($curl, CURLOPT_URL, "ftp://company@company.company.se/company/import.xml"); #input
curl_setopt($curl, CURLOPT_FILE, $file); #output
curl_setopt($curl, CURLOPT_USERPWD, "$_FTP[user]:$_FTP[password]");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$testcurl = curl_exec($curl);
curl_close($curl);
$xml = simplexml_load_file($testcurl);
foreach($xml->loanaccount as $mess){
$account_number= mysql_real_escape_string($mess->account_number);
$main= mysql_real_escape_string($mess->main);
//insert into databse
mysql_query("INSERT INTO account (account_number, main)
VALUES ('$account_number', '$main')")
or die(mysql_error());
echo "inserted into mysql<br /><br />";
//show updated records
printf ("Records inserted: %d\n", mysql_affected_rows());
}
This is the output I get:
connected to DB
Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "" in /www/webvol11/kh/ezjvt3700zfmb4q/company.se/public_html/service/test1.php on line 29
Warning: Invalid argument supplied for foreach() in /www/webvol11/kh/ezjvt3700zfmb4q/company.se/public_html/service/test1.php on line 30