Solved

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

Posted on 2004-04-01
6
189 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
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 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:
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

830 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