I am looking for a bit of advice on an issue with putting php code in a sidebox.
I am using version 1.3.8. Site link is: http://premier-coins.com
In the left hand sidebox labeled "Daily Spot Gold Prices".
Ultimately what I am trying to do is get current spot gold price and calculate 10k, 14k and 18k gram prices in an automated fashion. But I am learning PHP and that is my perfect world.
Reality sits in and for now all I want to do is to be able to read a number out of a text file that is uploaded to a directory. Then my php script will open the text file, read it and close it. Then the script will run 3 calculations and display them in the sidebox. On my WAMP server I have a standard php file with the following code, a text file and everything seems to work fine in my controlled enviroment.
Here is what I have.
PHP Code:$price = "goldspot.txt";
$gs = fopen($price,"r");
$goldSpot = fread($gs,7);
fclose($gs);
PHP Code:$tenK=round((($goldSpot * .417)/31.1)* .78,2);
$fourteenK=round((($goldSpot * .585)/31.1)*.78,2);
$twentyFourK=round((($goldSpot * 1)/31.1)*.78,2);
echo $goldSpot;
Like I said this seems to work fine on my WAMP server but when I move this to my side box and add the code (like below) then my variables don't change values when I update the value in the text file as they do on my WAMP server. I am not sure if this a sessions problem or other sidebox problem or if it is just me. Would I be better off putting this on with the main page content and forget about the sidebox? Any ideas or suggestions would be appreciate! Thanks in advance!HTML Code:<br /> <br /> 10Karat Gold = $<?php echo $tenK;?> per gram.<br /> 14Karat Gold = $<?php echo $fourteenK; ?> per gram.<br /> 24Karat Gold = $<?php echo $twentyFourK; ?> per gram<br />
PHP Code:$price = 0;
$tenK = 0;
$fourteenK = 0;
$twentyFourK = 0;
$gs = 0;
$goldSpot = 0;
$price = "goldspot.txt";
$gs = fopen($price,"r");
$goldSpot = fread($gs,7);
fclose($gs);
$tenK=round((($goldSpot * .417)/31.1)* .78,2);
$fourteenK=round((($goldSpot * .585)/31.1)*.78,2);
$twentyFourK=round((($goldSpot * 1)/31.1)*.78,2);
/**
* blank sidebox - allows a blank sidebox to be added to your site
*
* @package templateSystem
* @copyright 2007 Kuroi Web Design
* @copyright Portions Copyright 2003-2007 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: blank_sidebox.php 2007-05-26 kuroi $
*/
$content = '';
$content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">';
// Replace the text and HTML tags between the apostophes on lines 19 and 20.
// Use as many or as few lines using this model as you need for your custom content.
// If you have a multilingual site define your text in the languages/YOUR_LANGUAGE/extra_definitions/blank_sidebox_defines.php and include it as shown in line 19.
// If your site is monolingual, you can put the text right here as shown on line 20 (and nobody will know!)
$content .= '<span>' . TEXT_BLANK_SIDEBOX . '</span>';
$content .= '<span class="gold_pic"><img src="http://premier-coins.com/images/custom/images/gold_bar_sm.jpg" alt="gold image for spot gold pricing"></span><br /><span>Per Gram</spam><br />';
/* ***********UPDATE GOLD SPOT PRICES HERE *************** */
$content .= '<span><strong>
10K Gold $ ' . $tenK . '
<br />
14K Gold $ ' . $fourteenK . '
<br />
24K gold $ ' . $twentyFourK . '
</strong> <br /> <a style="font-size: 9px;">Prices subject to current Spot Gold Prices. Please call for current prices.<br />Updated Daily.<br /> Update 1-29-10.</span></div>';
$content .= '</div>';
-Gremlin




