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

Posted on 2004-04-01
Last Modified: 2006-11-17
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>";
Question by:cdukes
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 14

Expert Comment

ID: 10747318
               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..)
LVL 14

Accepted Solution

ThG earned 500 total points
ID: 10747327
ok forget the above comment, actually the double $$ has the behaviour i described only when used outside strings. So this shouldn't be a problem for you. fix it anyway as it is BAD coding..
               echo "<td align=\"center\" nowrap><font size=\"2\" color=\"green\"><b>\$$billrate.00</b></font></td>";

please show me some debugging output, specifically something like this at the end of your code:

Author Comment

ID: 10752172
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.
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.


Author Comment

ID: 10757703
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?
LVL 14

Expert Comment

ID: 10761044
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?

Author Comment

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

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Introduction This article is intended for those who are new to PHP error handling (  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question