Php fails if variable > 1082
PHP script fails if variable is more than 1082
Hello all. It's me...again [sigh].
I have a script that determines how much a person should be charged for space with my hosting company. All is well unless the person specifies they want an account w/ more than 1082 mb of space, and they want to pay for more than 1 month of hosting (i.e. 24 months).
It seems as though my varible is out of bounds and the number that I'm given is wrong.
An example can be found at:
http://www.cprhosting.com/index.php
First specify that the user wants 1082 space at 24 months.
Then try again to specify that the user wants 1083 space at 24 months.
See what I'm saying? Is there any way to force my variable to be a larger type? It's a float now, but it seems my floats have space limitations.
CPRhosting.com - CPR Hosting...Giving life to the web
Custom-made Hosting Plans starting at $2
mairving posted this at 17:09 — 10th March 2002.
They have: 2,256 posts
Joined: Feb 2001
I am assuming that this is being dumped into a database. If so, the first thing I always do is make sure that the SQL itself works. Take your insert statement from PHP and if this fails in MySQL, it will help you identify the problem.
In looking at your form, you should probably put a maximum size on the form field.
Posting your script here using the php tags would help us determine the problem.
Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states
Mark Hensler posted this at 20:12 — 10th March 2002.
He has: 4,048 posts
Joined: Aug 2000
1082 is such an odd number. Can we see any code associated with the problem?
shanda posted this at 02:19 — 11th March 2002.
They have: 105 posts
Joined: Jan 2002
$intV = array(1,12,24);
$percent = 10;
$unitBW = 1;
if ($valHD <= 0) $valHD = 50;
if ($valHD < 100) $perHD = 0.055;
elseif ($valHD <=300) $perHD = 0.0499;
elseif ($valHD <= 400) $perHD = 0.047475;
elseif ($valHD <= 500) $perHD = 0.04598;
elseif ($valHD <= 600) $perHD = 0.04665;
else $perHD = 0.035;
$valBW = $valBW / $unitBW;
$finalPrice =(($percent + 100)/100) *($valHD * $perHD);
if (($finalPrice - 2) > $paymentInterval) {
$finalPrice = $finalPrice - $paymentInterval;
}
$finalPrice = number_format($finalPrice, 2);
$payFirst = number_format(($finalPrice * $intV[$paymentInterval]), 2);
}
CPRhosting.com - CPR Hosting...Giving life to the web
Custom-made Hosting Plans starting at $2
Mark Hensler posted this at 05:17 — 11th March 2002.
He has: 4,048 posts
Joined: Aug 2000
I can't duplicate any errors. What values do I need to provide to get an error?
mairving posted this at 13:16 — 11th March 2002.
They have: 2,256 posts
Joined: Feb 2001
Question about this statement:
if (($finalPrice - 2) > $paymentInterval) {
$finalPrice = $finalPrice - $paymentInterval;
Here is what is said, if finalprice -2 less than paymentinterval
then finalprice = finalprice - paymentinterval. Okay but where does the paymentinterval value come from?
Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.