Here it goes:
I have a file that pulls market data from a outside source this is working fine. I display each of the prices from variables I define. All of them resolve to show the price. but as soon as I try a formula with them. Two of the variables work and two do not. I have tried striping out the code to only one variable (Gold) and it still does not work. I can not figure out why 2 of my my variables are working and two are not? PLEASE HELP!!!
[php]<?php
require_once(‘class/IsterXmlSimpleXMLImpl.php’);
function getQuoteList($arrSymbols = array(“XAUUSDOZ”,“XAGUSDOZ”,“XPTUSDOZ”,“XPDUSDOZ”)) {
$provider = “comstock_lite”;
$username = “XXXXXX”;
$password = “XXXXXXX”;//edited by moderator
$dateTimeFormat = "HH:mm:ss"; //The format for returned timestamps
$timezone = "America/New_York"; //The timezone to which timestamps should be converted
//Returns a full text-representation of the XML document
//with the given URL.
// function getXMLSource($url)
// {
// $str = file_get_contents($url);
// return $str;
// }
//Create a string representation of the symbols, seperated by "|"
$strSymbols = "";
$start = 0;
foreach($arrSymbols as $symbol)
{
$strSymbols = $strSymbols.$symbol."|";
}
// $source = getXMLSource("http://balancer.netdania.com/StreamingServer/StreamingServer?xml=price&group=".$username."&pass=".$password."&source=".$provider."&symbols=".$strSymbols."&fields=10|11|14|15|25|2|3&time=".$dateTimeFormat."&tzone=".$timezone);
//Load XML data source
$impl = new IsterXmlSimpleXMLImpl;
$objXMLDom = $impl->load_file("http://balancer.netdania.com/StreamingServer/StreamingServer?xml=price&group=".$username."&pass=".$password."&source=".$provider."&symbols=".$strSymbols."&fields=10|11|14|15|25|2|3&time=".$dateTimeFormat."&tzone=".$timezone);
//echo "<pre>";
//print_r($objXMLDom);
//echo "</pre>";
//echo "http://balancer.netdania.com/StreamingServer/StreamingServer?xml=price&group=".$username."&pass=".$password."&source=".$provider."&symbols=".$strSymbols."&fields=10|11|14|15|25|2|3&time=".$dateTimeFormat."&tzone=".$timezone;
return $objXMLDom;
}
?>
<?php
$objXMLDom = getQuoteList();
$i = 0;
$arrNames = array("Gold", "Silver","Platinum","Palladium");
//Loop through and display data for each instrument
foreach ($objXMLDom->datafeed->children() as $quote) {
$quoteinfo = $quote->attributes();
/*echo "<pre>";
print_r($quoteinfo);
echo "</pre>"; */
$strName = $arrNames[$i];
$i++;
$strBid = $quoteinfo["f10"];
$strAsk = $quoteinfo["f11"];
$strChange = $quoteinfo["f14"];
$strPercChange = $quoteinfo["f15"];
$strHigh = $quoteinfo["f2"];
$strLow = $quoteinfo["f3"];
$strDateTime = $quote->CDATA();
?>
<?
if ($strName == "Gold") {
$GoldAsk = $strAsk ;
$GoldAsk = number_format ($GoldAsk, 2);
}
?>
<?
if ($strName == "Silver") {
$SilverAsk = $strAsk ;
$SilverAsk = number_format ($SilverAsk, 2);
}
?>
<?
if ($strName == "Platinum") {
$PlatinumAsk = $strAsk ;
$PlatinumAsk = number_format ($PlatinumAsk, 2);
}
?>
<?
if ($strName == "Palladium") {
$PalladiumAsk = $strAsk;
$PalladiumAsk = number_format ($PalladiumAsk, 2);
}
?>
<?
}
$xml = null;
?>
<?php
/*
print("The spot price of gold is currently -- <strong>$GoldAsk</strong>");
print("<br />");
print("<br />");
print("The spot price of silver is currently -- <strong>$SilverAsk</strong>");
print("<br />");
print("<br />");
print date ('g:i a D. F j, Y');
*/
?>
<?php
// BULLION PRICING ROUTINE
// ### adjust these as necessary – ONE OUNCE MULTIPLIERS FOR PRICE CALCS ####
$GoldOne = .88 ;
$GoldKilo = 1.05 ;
$Silver100 = 1.05;
$Silver1000 = .88;
$PlatinumOne = 1.05;
$PlatinumTen = .99;
$PlladiumOne = .99;
// You likely won’t want to touch any of the following equations
$GoldOnePrice =$GoldAsk * $GoldOne ;
$GoldOneEyes = number_format ($GoldOnePrice, 2);
$Silver100Price =$SilverAsk * $Silver100;
$Silver100Eyes = number_format ($Silver100Price, 2);
$Silver1000Price =$SilverAsk * $Silver1000;
$Silver1000Eyes = number_format ($Silver1000Price, 2);
$PlatinumOnePrice =$PlatinumAsk * $PlatinumOne;
$PlatinumOneEyes = number_format ($PlatinumOnePrice, 2);
$PlatinumTenPrice =$PlatinumAsk * $PlatinumTen;
$PlatinumTenEyes = number_format ($PlatinumTenPrice, 2);
$PlladiumOnePrice =$PalladiumAsk * $PlladiumOne;
$PlladiumOneEyes = number_format ($PlladiumOnePrice, 2);
?>
Gold <?php print "$GoldAsk"; ?>
GoldOne <?php print "$GoldOneEyes"; ?>
Silver <?php print "$SilverAsk"; ?>
Silver100 <?php print "$Silver100Eyes"; ?>
Silver1000 <?php print "$Silver1000Eyes"; ?>
Platinum <?php print "$PlatinumAsk"; ?>
PlatinumOne: <?php print "$PlatinumOneEyes"; ?>
PlatinumTen: <?php print "$PlatinumTenEyes"; ?>
Plladium: <?php print "$PalladiumAsk"; ?>
PlladiumOne: <?php print "$PlladiumOneEyes"; ?>