?
Solved

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

Posted on 2004-04-01
6
Medium Priority
?
192 Views
Last Modified: 2006-11-17
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>";
                }
0
Comment
Question by:cdukes
[X]
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
6 Comments
 
LVL 14

Expert Comment

by:ThG
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..)
0
 
LVL 14

Accepted Solution

by:
ThG earned 1500 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:
var_dump($unit,$rate,$commitment,$excess,$excessrate,$billrate);
0
 

Author Comment

by:cdukes
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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:cdukes
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?
0
 
LVL 14

Expert Comment

by:ThG
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?
0
 

Author Comment

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

Featured Post

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

764 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