cb154 Posted February 17, 2010 Share Posted February 17, 2010 Hi, I am making a call and getting an array returned which appears like this Result stdClass Object ( [GetHistoricalCrossRatesRangeResult] => stdClass Object ( [Outcome] => Success [identity] => IP [Delay] => 0.016 [symbol] => USDEUR [From] => stdClass Object ( [symbol] => USD [Name] => United States Dollar ) [To] => stdClass Object ( [symbol] => EUR [Name] => Euro ) [CrossRates] => stdClass Object ( [CrossRateItem] => Array ( [0] => stdClass Object ( [Date] => 2/16/2010 [First] => 0.73539415207652 [Last] => 0.72663855924982 [High] => 0.73589741835227 [Low] => 0.72569994084434 I have written some code to put this into a mysql database but I am having some problems. The date is not being returned and the decimal numbers are being rounded. I am a newbie and my code looks like this $max = sizeof($result->GetHistoricalCrossRatesRangeResult->CrossRates->CrossRateItem); for ($i = 0; $i<=$max; $i++) { $Ccy = $result->GetHistoricalCrossRatesRangeResult->Symbol; $TSDate = $result->GetHistoricalCrossRatesRangeResult->CrossRates->CrossRateItem->$i->Date; $First = (double)$result->GetHistoricalCrossRatesRangeResult->CrossRates->CrossRateItem->$i->First; $Last = (double)$result->GetHistoricalCrossRatesRangeResult->CrossRates->CrossRateItem->$i->Last; $High = (double)$result->GetHistoricalCrossRatesRangeResult->CrossRates->CrossRateItem->$i->High; $Low = (double)$result->GetHistoricalCrossRatesRangeResult->CrossRates->CrossRateItem->$i->Low; $query = "Insert into FXRates (CCy, TSDate, First, Last, High, Low) values ('$Ccy', '$TSDate', $First, $Last, $High, $Low)"; mysql_query ($query) or die ("Query failed: " . mysql_error() . " Actual Query: " . $query); } when i check my query I am getting Insert into FXRates (CCy, TSDate, First, Last, High, Low) values ('USDEUR', '', 0, 0, 0, 0) can anyone point out my mistake please. Link to comment https://forums.phpfreaks.com/topic/192406-php-array-processing-to-mysql/ Share on other sites More sharing options...
gamblor01 Posted February 17, 2010 Share Posted February 17, 2010 I guess I'm even more of a newbie. I can't comment on the code but I'm wondering where you got that array output from (the result stdClass Object stuff)? How does one generate that given an array in PHP? Link to comment https://forums.phpfreaks.com/topic/192406-php-array-processing-to-mysql/#findComment-1013848 Share on other sites More sharing options...
cb154 Posted February 17, 2010 Author Share Posted February 17, 2010 That is coming from a SOAP call and returning the details to me in an array which I am trying to then shred into the MYSql database. Link to comment https://forums.phpfreaks.com/topic/192406-php-array-processing-to-mysql/#findComment-1013849 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.