Link to home
Start Free TrialLog in
Avatar of cdukes
cdukesFlag for United States of America

asked on

Code Execution - works on one page and not on another -- same code

Hi,
I'll try to get this right, but it's a bit involved.

I've built a billing database for my company (I work for an ISP).
The database lists customers, their bill rate, their commitment level (in MB or GB) and a few other things.
I have a function that calculates a customer's 95th percentile usage (from a perl script) for the month and places that value into a field -- this peice is working correctly

Based on this result, I then make some calculations for each customer based on their bill rate, commit level, etc. and print a dollar amount in another field.

Problem: If I search on a single customer everything works fine.
If I list more than one customer per page (default 10 when the user logs in) it prints the bandwidth utilization properly (result from the perl file) but does not print the bill calculation.

What confuses me is that these two views are using the exact same code to do the calculation.
I thought that maybe is was a max_execution time setting in php.ini but that is set to 600 seconds -- plenty of time.
Also, as noted before -- the perl results are returning correctly -- it's the internal (no external scripts) function results that aren't printing.

Here is my calculation within php:
   $unit = $field_4;
   $rate = $field_5;
   $commitment = $field_6;
   $excess = $field_7;
   $excessrate = $field_8;
   $billrate = "";
        if ($field_2) {
                if ( $unit == "Mb") {
                        $ninetyfive = ninetyfive($field_2);
                        echo $ninetyfive;
                } else {
                        echo "";
                }
                }
// Begin Calculation for EOM bill rate)
                if ($ninetyfive) {
                        if ($rate > 0) {
                                if ($commitment > 0 ) {
                                        if ( $ninetyfive > $commitment ) {
                                                $over = ceil(( $ninetyfive - $commitment ) / $excess) * $excess;
                                                $billrate = ( $over * $excessrate / $excess);
                                        } else {
                                                $billrate = "";
                                        }
                                }
                        }
                }
   // End Calculation for bill rate (ALMOST) -> see echo statement below
        }
   echo "</font></td>";
        // Print Bill rate line
        if ($billrate) {
                echo "<td align=\"center\" nowrap><font size=\"2\" color=\"green\"><b>$$billrate.00</b></font></td>";
        } else {
                        echo "<td align=\"center\" nowrap><font size=\"1\" color=\"$font_color\"></font></td>";
                }
Avatar of Giovanni G
Giovanni G
Flag of Italy image

               echo "<td align=\"center\" nowrap><font size=\"2\" color=\"green\"><b>$$billrate.00</b></font></td>";

why double $$? it means that you want the value in the variable whose name is the content of $billrate (probably a non existent variable..)
ASKER CERTIFIED SOLUTION
Avatar of Giovanni G
Giovanni G
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cdukes

ASKER

All the double dollar does is prints a dollar symbol in front of the output so that the user sees "$amount" on the web page instead of "amount".

I am out of town at the moment but will return Monday and will get the debug output.
Avatar of cdukes

ASKER

I've spent the last hour fixing my code -- I'm not sure what I had done wrong, but your var_dump suggestion certainly started me on the right path. I didn't know about that command -- very useful, thanks.
After cleaning up the code, it is now working properly.

Shall I award you full points for this?
Well, theorically yes, as stated in the help section, a solution is considerable acceptable if it address you to the resolution of your problem.

I suggest a "B" grade for this. Although if you'd prefer you can ask for moderator's opinion about what to do (decreasing question points could be a solution but i've been in EE for more than one year and this doesn't look a used practice).

Have you got any other question regarding this topic?
Avatar of cdukes

ASKER

No problem -- I'll award the points to you, I just wasn't aware of the proper protocol. Thanks for the help ;-)