Solved

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

Posted on 2004-04-01
6
186 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
  • 3
  • 3
6 Comments
 
LVL 14

Expert Comment

by:ThG
Comment Utility
               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 500 total points
Comment Utility
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
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:cdukes
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now