FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


help me resolve this weird error in php





metalfreek
I am trying to make a php cart system and I am stuck with a logical or syntax bug which is making me mad. Here is what I am facing

I am trying to get cart total in two currency (USD & INR) and whenever my total exceeds 53000 (not an exact number but somewhere around that) I get $exchangerate instead of total amount. As long as the total is less than 53400 the math is correct but this bug starts once it exceeds 53400. What is wrong with the code? The actual code is long so I will post some snippet here

My primary currency is USD and INR is my second currency.

My way of calculating price in INR, $exchangerate is taken for Yahoo finance.
Code:
number_format($exchangerate*$price, 2)

Code:
number_format($exchangerate*$pricetotal, 2)

Code:
number_format($exchangerate*$cartTotal, 2)
darthrevan
I don't know much of programming and php, though it may not work; have you tried putting double quotes around exchangerate*VARIABLE

I am guessing the code post for exchangerate*cartTotal is missing its parentheses only on the forum Razz

Just out of curiosity if you do a conditional saying if above the amount that gives you a problem do Formula. probably won't make any difference but is a thought.

So it would be if total > 53400 do exchangerate*cartTotal
metalfreek
darthrevan wrote:
I don't know much of programming and php, though it may not work; have you tried putting double quotes around exchangerate*VARIABLE

I am guessing the code post for exchangerate*cartTotal is missing its parentheses only on the forum Razz

Just out of curiosity if you do a conditional saying if above the amount that gives you a problem do Formula. probably won't make any difference but is a thought.

So it would be if total > 53400 do exchangerate*cartTotal


Ya the parentheses was missing on the forum only. I am still stuck with this error even after putting double quotes.
rx9876
I am not sure, but I guess it might be over the limit of integer.
The integer limit is 2147483647.
You could try to use float instead of integer and try again.
darthrevan
rx9876 wrote:
I am not sure, but I guess it might be over the limit of integer.
The integer limit is 2147483647.
You could try to use float instead of integer and try again.

I doubt 53400 is bigger than that limit. Though you might want to use a float and see if that helps. If I remember correctly , floats shows decimal points.
metalfreek
As mentioned above php has a huge integer limit for numbers so its not the issue as far as I can tell. I will definitely try with floats and see what happens. Thank you all for the input.
imagefree
var_dump( ) the combinition of values that creates the problem and paste it here.
Also paste the outcome that you think is wrong.
rx9876
metalfreek wrote:
As mentioned above php has a huge integer limit for numbers so its not the issue as far as I can tell. I will definitely try with floats and see what happens. Thank you all for the input.


I misunderstood the question description.
You could try to use xdebug to trace the program running.
http://xdebug.org/
Related topics
need help in a simple php register script based on flat file
Weird "Failure to Open Stream" Error
error with cash mod
Need help with an error
If you need help with php-nuke
Help with a quick PHP mod for PHPBB.
PHP-Nuke Services
Problem with avatar
Error (ERROR_PLATFORM_FAILURE)
The requested URL /\"compose.php\" was not found o
Mail Server Authentication Setup Problem
Php Warning: fopen
Free professional video editing software?
SquirrelMail ERROR
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.