Page 1 of 1

php code help-- am not sure what is wrong here

Posted: Mon Nov 16, 2009 11:19 am
by vonnero
the following code return 0, it does not do the computation. Please can anybody help? am not sure if its the string convertion that is the problem.
Been trying out various options.
Pls help

public function Report_Target_Revenue($id){


$discount=0.85; //at 15%
$days=$this->Report_Duration($id); // returns 4
$daily_rate=$this->Report_Rate($id);// returns 28

$target_del=$this->Report_Target_Delegate($id);// returns 7

$target_revenue=$days * $daily_rate * $target_del * $discount;


return $target_revenue;

Re: php code help-- am not sure what is wrong here

Posted: Tue Nov 17, 2009 2:19 am
by vonnero
i have tested all of them, they return the expected values.

i need some help

Re: php code help-- am not sure what is wrong here

Posted: Tue Nov 17, 2009 2:35 am
by iankent
Not sure what to suggest, if all the functions are returning the correct values then it should work. When you say 'string conversion', what do you mean? Nothing there appears to be converted from a string?

I'd start by changing this line:

Code: Select all

$target_revenue=$days * $daily_rate * $target_del * $discount;
to this:

Code: Select all

$target_revenue=$days;
And see if it returns the correct value. If it does, add in * $daily_rate and try again, e.g.:

Code: Select all

$target_revenue=$days * $daily_rate;
and so on until you're back to the original line.

When your function suddenly returns 0, the last variable you're multiplying by is the one causing the problem.

Re: php code help-- am not sure what is wrong here

Posted: Tue Nov 17, 2009 9:21 am
by vonnero
many thanks.... my mistake, i was returning the value wrapped in a div;

solved now