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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vonnero
Forum Newbie
Posts: 17
Joined: Tue Feb 17, 2009 6:19 am

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

Post 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;
vonnero
Forum Newbie
Posts: 17
Joined: Tue Feb 17, 2009 6:19 am

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

Post by vonnero »

i have tested all of them, they return the expected values.

i need some help
User avatar
iankent
Forum Contributor
Posts: 333
Joined: Mon Nov 16, 2009 4:23 pm
Location: Wales, United Kingdom

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

Post 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.
vonnero
Forum Newbie
Posts: 17
Joined: Tue Feb 17, 2009 6:19 am

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

Post by vonnero »

many thanks.... my mistake, i was returning the value wrapped in a div;

solved now
Post Reply