I think I have a variable Problem

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"; ?>

[/php]

Hmmm, hkitty,

I have looked and looked and can not find anything wrong with the code you posted.
I can only think that something unseen is causing the problem. This could be code I can not see.
Can you duplicate the error with simple lines? Have you verified that the input to your routines is
actually a float and not a string? A string could be interpreted as a hex char. Also, if you are sending
a zero into formulas, this could cause a problem. Have you echo’d the actual data at various places
in the code to track the real values?
If you can duplicate the error without posting all your blocked out code, send that to us…

Sorry for no useful info here, guessing after an hour of finding nothing wrong in your code…

Sponsor our Newsletter | Privacy Policy | Terms of Service