Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
magiqhand
New Member
New Member



Joined: Mar 23, 2005
Posts: 17

PostPosted: Wed Mar 23, 2005 11:29 pm Reply with quote

Hello
I need help fixing the divide by zero problem in As-currency 2.0. I tried to look at the fix in austin smoke website but the website is currently not working can somebody help.Here is the message I am getting when I try to convert currencies: ERROR 501-1.ERROR 501-1.
Warning: Division by zero in /home/nigerpor/public_html/home/modules/AS-Currency/index.php on line 78
Thks
 
View user's profile Send private message
sixonetonoffun
Spouse Contemplates Divorce



Joined: Jan 02, 2003
Posts: 2496

PostPosted: Thu Mar 24, 2005 7:59 am Reply with quote

You probably have to find the line of code on 78 and add something like
if($divisor == 0){ echo "<h1>Error:No value defined</h1>"; exit;}

_________________
[b][size=5]openSUSE 11.4-x86 | Linux 2.6.37.1-1.2desktop i686 | KDE: 4.6.41>=4.7 | XFCE 4.8 | AMD Athlon(tm) XP 3000+ | MSI K7N2 Delta-L | 3GB Black Diamond DDR
| GeForce 6200@433Mhz 512MB | Xorg 1.9.3 | NVIDIA 270.30[/size:2b8 
View user's profile Send private message
magiqhand







PostPosted: Thu Mar 24, 2005 5:42 pm Reply with quote

That doesn't fix my problem. Here is what the code looks like
Confused <?php

/************************************************************************************/
/* */
/* AustinSmoke Scripts Exchange Rates (Currency Converter) */
/* Module and Block: AS-Currency */
/* v2.0: 05 Feb 2004 - For PHP-Nuke 6.9+ */
/* */
/* Copyright © 2003-2004 by: AustinSmoke Scripts (scripts@austinsmoke.com) */
/* [ Only registered users can see links on this board! Get registered or login! ] */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/* */
/************************************************************************************/

if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
die ("You can't access this file directly...");
}

//open PHPNuke tables
include("header.php");
OpenTable();
$index = 1;


//start of AS_Currency module
$module_name = basename( dirname( __FILE__ ) );

require_once( "mainfile.php" );
require_once( "modules/$module_name/class.ascurrency.php" );


function Convert( $module_name, $qty, $a, $b, $uptime )
{
global $db, $prefix;

//get setup values
$query = "SELECT * FROM $prefix"._ascurrency_setup."";
$result = $db->sql_query($query) or die ("ERROR 401");
$numofrows = $db->sql_numrows($result);

for($y = 0; $y < $numofrows; $y++)
{
$row = $db->sql_fetchrow($result);
$setupvar[$y] = $row['name'];
$$setupvar[$y] = $row['value'];
}

//get info about market (a)
$query = "SELECT * FROM $prefix"._ascurrency_data." where iso = '$a'";
$result = $db->sql_query($query) or die ("ERROR 423");
$row = $db->sql_fetchrow($result);
$namea = $row['country'];
$flaga = $row['flag'];
$sourcea = $row['source'];
$timea = $row['updated'];

//get info about market (b)
$query = "SELECT * FROM $prefix"._ascurrency_data." where iso = '$b'";
$result = $db->sql_query($query) or die ("ERROR 425");
$row = $db->sql_fetchrow($result);
$nameb = $row['country'];
$flagb = $row['flag'];
$sourceb = $row['source'];
$timeb = $row['updated'];

//grab time and convert both currencies
$now = time();

$asc = new ascurrency();

$valuea = $asc->update_code($now, $uptime, $a, $sourcea);
$valueb = $asc->update_code($now, $uptime, $b, $sourceb);

//compare one value to the next and save to display
if($divisor == 0){ echo "<h1>Error:No value defined</h1>"; exit;}
$display = round((($valueb / $valuea) * $qty),5);

echo "<table width=\"50%\" cellspacing=\"0\" cellpadding=\"0\" border=\"2\" frame=\"border\" rules=\"none\" align=\"center\">
<tr bgcolor=\"black\"><td><font color=\"white\"><strong>Your Conversion Results</strong></font></td></tr>
<tr><td>

<table align=\"center\" valign=\"top\" cellspacing=\"5\">
<tr>
<td valign=\"top\"><img width=$color_flagwidth height=$color_flagheight src=\"modules/".$module_name."/images/flags/".$flaga."\"></td>
<td valign=\"center\"><strong>$qty $namea(s)</strong> (ISO Code: <strong>$a</strong>)</td>
</tr>
<tr>
<td valign=\"top\"><img width=$color_flagwidth height=$color_flagheight src=\"modules/".$module_name."/images/flags/".$flagb."\"></td>
<td valign=\"center\"><strong>$display $nameb(s)</strong> (ISO Code: <strong>$b</strong>)</td>
</tr>
</table>

</td></tr>";

echo "<tr><td height=\"50\" valign=\"middle\" align=\"center\">";
if($timea == $timeb)
{
if($timea == 0) {$timea = $now;}
echo "Values are approximately: ".round((($now - $timea) / 60),0)." minutes old.";
}
else
{
if($timea == 0) {$timea = $now;}
if($timeb == 0) {$timeb = $now;}
if($timea > $timeb)
{
echo "Values are approximately: ".round((($now - $timea) / 60),0)." - ".round((($now - $timeb) / 60),0)." minutes old.";
}
elseif($timea < $timeb)
{
echo "Values are approximately: ".round((($now - $timeb) / 60),0)." - ".round((($now - $timea) / 60),0)." minutes old.";
}
}

if($display == 0)
{
echo "<p><center><font color=\"red\">It seems that the currency you have requested may currently be unavailable or may no longer be valid. If you feel that you have received this message in error, please email the site administrator.</font></center></p>";
}
echo "</td></tr>";

echo "<tr><td height=\"110\" valign=\"bottom\"><strong>Please note:</strong> This in only an estimate of what the current market values represent. While it should be accurate within the above timeframe, it is NOT a real time quote and should not be used for investment purposes.<p> Furthermore, the author of this website assumes no responsibility for inaccurate or otherwise misleading data.</p></td></tr>";

echo "<tr><td>
<table width=\"100%\" cellpadding=\"5\">
<tr>
<td><center><a href=\"http://www.oanda.com\"><img border=\"0\" src=\"modules/$module_name/images/logos/logo_small_oanda.gif\"></a></center></td>
<td><center><a href=\"http://finance.yahoo.com/m3?u\"><img border=\"0\" src=\"modules/$module_name/images/logos/logo_small_yahoo.gif\"></a></center></td>
<td><center><a href=\"http://money.cnn.com/markets/currencies/\"><img border=\"0\" src=\"modules/$module_name/images/logos/logo_small_cnn.gif\"></a></center></td>
</tr>
</table>
</td></tr>

</table>";

}

function DisplayInput( $module_name, $qty, $a, $b )
{

global $db, $prefix;

//get setup values
$query = "SELECT * FROM $prefix"._ascurrency_setup."";
$result = $db->sql_query($query) or die ("ERROR 401");
$numofrows = $db->sql_numrows($result);

for($y = 0; $y < $numofrows; $y++)
{
$row = $db->sql_fetchrow($result);
$setupvar[$y] = $row['name'];
$$setupvar[$y] = $row['value'];
}

$marketvalue = 1;

if(!($qty == ""))
{
$market = $a;
$marketb = $b;
$marketvalue = $qty;
}

$query = "SELECT * FROM $prefix"._ascurrency_data." order by country";
$result = $db->sql_query($query) or die ("ERROR 450");
$numofrows = $db->sql_numrows($result);

echo "<table width=\"50%\" cellspacing=\"0\" cellpadding=\"0\" border=\"2\" frame=\"border\" rules=\"none\" align=\"center\">
<tr bgcolor=\"black\"><td><font color=\"white\"><strong>Currency Conversion Settings</strong></font></td></tr>
<tr><td>

<form action=\"modules.php?name=".$module_name."\" method=\"POST\">
<table valign=\"top\" cellspacing=\"5\" align=\"center\">

<tr>
<td align=\"right\"><strong>Convert: </strong></td>
<td align=\"left\">
<input type=\"text\" name=\"qty\" value=\"$marketvalue\" size=\"15\">
</td>
</tr>

<tr>
<td align=\"right\">from: </td>
<td valign=\"top\" align=\"left\">
<select name=\"cfrom\">";
for($j = 0; $j < $numofrows; $j++)
{
$isselected = "";
$row = $db->sql_fetchrow($result);
if(($row['iso']) == $market)
{
$isselected = "selected";
}
echo "<option $isselected>".$row['country']."</option>";
}
echo "</select>
</td>
</tr>

<tr>
<td align=\"right\">to: </td>
<td valign=\"top\" align=\"left\">
<select name=\"cto\">";

$query = "SELECT * FROM $prefix"._ascurrency_data." order by country";
$result = $db->sql_query($query) or die ("ERROR 453");
$numofrows = $db->sql_numrows($result);

for($j = 0; $j < $numofrows; $j++)
{
$isselected = "";
$row = $db->sql_fetchrow($result);
if(($row['iso']) == $marketb)
{
$isselected = "selected";
}
echo "<option $isselected>".$row['country']."</option>";
}
echo "</select>
</td>
</tr>

<tr>
<td height=\"80\" colspan=\"2\">
<table align=\"center\">
<tr>
<td align=\"bottom\" height=\"80\"><input type=\"submit\" value=\"Convert Currencies\"></td>
<td align=\"bottom\" height=\"80\"><input type=\"reset\" value=\"Reset Current Form\"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</td></tr>
</table>";

}

function GetISO( $c )
{
global $db, $prefix;
$query = "SELECT * FROM $prefix"._ascurrency_data." where country='$c'";
$result = $db->sql_query($query) or die ("ERROR 420");
$row = $db->sql_fetchrow($result);

return $row['iso'];

}


/************************************************************
//Start of Main Program
************************************************************/

$qty = $_POST["qty"];
$a = $_POST["cfrom"];
$b = $_POST["cto"];

//get setup values
$query = "SELECT * FROM $prefix"._ascurrency_setup."";
$result = $db->sql_query($query) or die ("ERROR 401");
$numofrows = $db->sql_numrows($result);

for($y = 0; $y < $numofrows; $y++)
{
$row = $db->sql_fetchrow($result);
$setupvar[$y] = $row['name'];
$$setupvar[$y] = $row['value'];
}


echo "<table width=\"100%\" align=\"center\" cellpadding=\"10\">
<tr><td align=\"center\"><h4>AustinSmoke Currency Converter v2.0</h4></td></tr>";

if(!($a == ""))
{
$a = GetISO( $a );
$b = GetISO( $b );
}

echo "<tr><td>";
DisplayInput( $module_name, $qty, $a, $b );
echo "</td></tr>";


if(!($qty == ""))
{
echo "<tr><td>";

Convert( $module_name, $qty, $a, $b, $uptime );

echo "</td></tr>";
}



echo "</table>";


//close PHPNuke Tables
CloseTable();
include("footer.php");

?>
 
sixonetonoffun







PostPosted: Thu Mar 24, 2005 7:12 pm Reply with quote

Ok I don't have the include file where the function update_code() is defined. But it might be better to use floor() instead of round. There are some good examples here [ Only registered users can see links on this board! Get registered or login! ] that should give you some idea of how to work around the / 0 problem.

And this would have worked better if you changed the name of $divisor to the divisor Razz
if($divisor == 0){ echo "<h1>Error:No value defined</h1>"; exit;}
 
magiqhand







PostPosted: Thu Mar 24, 2005 10:04 pm Reply with quote

I tried what you have suggested it still didn't fix the problem. It keeps displaying error:No value define. I am not sure why. Thanks again for your help. Do you know somebody I can get the file from by chance.I've been on it for a while now and I still can't figure it out
 
sixonetonoffun







PostPosted: Fri Mar 25, 2005 8:27 am Reply with quote

If you run can get me the complete module I'll take a look at it.
 
magiqhand







PostPosted: Fri Mar 25, 2005 11:32 am Reply with quote

do you have the module in question or you need me to send you the files.
Thank you for your patience
 
sixonetonoffun







PostPosted: Fri Mar 25, 2005 12:00 pm Reply with quote

You could email them to sixonetonoffun <*> netflake.com also please include your php info ie version, If it is installed as cgi or apache module, so we are on the same page with the environment your using.
 
kypdr
New Member
New Member



Joined: Feb 22, 2007
Posts: 17

PostPosted: Fri Feb 23, 2007 11:38 am Reply with quote

I have this installed and everything looks good except it isn't updating any conversions or data? Any ideas?
 
View user's profile Send private message
rudolfpietersma
New Member
New Member



Joined: Mar 02, 2007
Posts: 3
Location: Emmen, Netherlands

PostPosted: Mon Mar 12, 2007 2:42 pm Reply with quote

I habe the same problem, it's not updating any info??
Is the module/project dead?
 
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Mon Mar 12, 2007 9:27 pm Reply with quote

I had a quick look on their website ans they state the module was tested on phpNuke v 6.9 so I'd guess it is pretty old now and no longer being developed.
The release date is given as February 5th 2004
 
View user's profile Send private message Send e-mail
rudolfpietersma







PostPosted: Tue Mar 13, 2007 12:22 am Reply with quote

Hi Raven,
Thnx for your response.

Do you know another module or block that has Currency / Exchange Rates in it?

Cheers,
Rudolf.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©