Welcome to Geeklog, Anonymous Tuesday, April 30 2024 @ 06:00 am EDT

Geeklog Forums

Staticpages and PHP


Status: offline

Uffe

Forum User
Junior
Registered: 02/01/04
Posts: 30

I include another site to my static pages:

@include("http://online.danskebank.dk/DK?gsProdukt=INF&gsNextObj=Valuta&gsNextAkt=VAList&gsSprog=DA&gsCurItem=DB?&quotWink;
It works fine.

But how can i put it in a table to adjust the width, this is my attempt:
<table width="600"><tr><td>
@include("http://online.danskebank.dk/DK?gsProdukt=INF&gsNextObj=Valuta&gsNextAkt=VAList&gsSprog=DA&gsCurItem=DB?&quotWink; </td></tr></table>

But i get this error:
Parse error: parse error, unexpected '<' in /var/www/html/public_html/staticpages/index.php(84) : eval()'d code on line 1


I am using 1.3.9sr1
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
Quote by Uffe:But i get this error:
Parse error...
not unexpected when mixing HTML and PHP without using any PHP open and close tags.

try a "?>" before your HTML and a "<?PHP" after your HTML and before your PHP. so like this:

?>
table stuff here
<?PHP
php code here
?>
more table stuff here
<?PHP
 Quote

Status: offline

Uffe

Forum User
Junior
Registered: 02/01/04
Posts: 30
It works fine
Thanks.
 Quote

affero

Anonymous
I get this same error. The problem is I think the code is OK. I am no php expert so it is hard to see if there is a problem. Truthfully, I don't even know if i am placing the code in the right place. What I have done is enabled php to "execute" and placed this code directly on a static page. When I try and see it I get the same error.

Parse error: parse error, unexpected '

here is the code I am trying to use. Can anyone see anything strange?

Text Formatted Code

        /*
                PHP Mortgage Calculator
                version: 1.1
                last update: Jan 1, 2003
                ----------------------------------------------------
                The PHP Mortgage Calculator tries to figure out a home
                owners mortgage payments, and the breakdown of each monthly
                payment.
               
                The calculator accepts:
                        Price (cost of home in US Dollars)
                        Percentage of Down Payment
                        Length of Mortgage
                        Annual Interest Rate
               
                Based on the four items that the user enters, we can figure
                out the down payment (in US Dollars), the ammount that the
                buyer needs to finance, and the monthly finance payment.
                The calculator can also break down the monthly payments
                so we know how much goes towards the mortgage's interest,
                the mortgage's principal, the loan's Private Mortgage Insurance
                (if less that 20% was used as a down payment), and an rough
                estimate of the property's residential tax
               
                [ See below for LICENSE ]
        */
       
        /* --------------------------------------------------- *
         * Set Form DEFAULT values
         * --------------------------------------------------- */
        $default_sale_price              = "200000";
        $default_annual_interest_percent = 6.5;
        $default_year_term               = 30;
        $default_down_percent            = 10;
        $default_show_progress           = TRUE;
        /* --------------------------------------------------- */
       


        /* --------------------------------------------------- *
         * Initialize Variables
         * --------------------------------------------------- */
        $sale_price                      = 0;
        $annual_interest_percent         = 0;
        $year_term                       = 0;
        $down_percent                    = 0;
        $this_year_interest_paid         = 0;
        $this_year_principal_paid        = 0;
        $form_complete                   = false;
        $show_progress                   = false;
        $monthly_payment                 = false;
        $show_progress                   = false;
        $error                           = false;
        /* --------------------------------------------------- */


        /* --------------------------------------------------- *
         * Set the USER INPUT values
         * --------------------------------------------------- */
        if (isset($_REQUEST['form_complete'])) {
                $sale_price                      = $_REQUEST['sale_price'];
                $annual_interest_percent         = $_REQUEST['annual_interest_percent'];
                $year_term                       = $_REQUEST['year_term'];
                $down_percent                    = $_REQUEST['down_percent'];
                $show_progress                   = (isset($_REQUEST['show_progress'])) ? $_REQUEST['show_progress'] : false;
                $form_complete                   = $_REQUEST['form_complete'];
        }
        /* --------------------------------------------------- */
       
       
        // If HTML headers have not already been sent, we'll print some here   
        if (!headers_sent()) {
                print("n");
                print("Mortgage Calculatorn");
                print("n");
                print("PHP Mortgage Calculatorn");
                print("<b>Printer Version</b> [ <a href="http://dave.imarc.net/mortgage">full version</a> ]<br>n");
                print("<hr>nn");
                $print_footer = TRUE;
        } else {
                $print_footer = FALSE;
        }
                // Style Sheet
        ?>
                                                /* --------------------------------------------------- */
        // This function does the actual mortgage calculations
        // by plotting a PVIFA (Present Value Interest Factor of Annuity)
        // table...
        function get_interest_factor($year_term, $monthly_interest_rate) {
                global $base_rate;
               
                $factor      = 0;
                $base_rate   = 1 + $monthly_interest_rate;
                $denominator = $base_rate;
                for ($i=0; $i
                        $factor += (1 / $denominator);
                        $denominator *= $base_rate;
                }
                return $factor;
        }                       /* --------------------------------------------------- */

        // If the form is complete, we'll start the math
        if ($form_complete) {
                // We'll set all the numeric values to JUST
                // numbers - this will delete any dollars signs,
                // commas, spaces, and letters, without invalidating
                // the value of the number
                $sale_price              = ereg_replace( "[^0-9.]", "", $sale_price);
                $annual_interest_percent = eregi_replace("[^0-9.]", "", $annual_interest_percent);
                $year_term               = eregi_replace("[^0-9.]", "", $year_term);
                $down_percent            = eregi_replace("[^0-9.]", "", $down_percent);
               
                if (((float) $year_term
                        $error = "You must enter a <b>Sale Price of Home</b>, <b>Length of Motgage</b> <i>and</i> <b>Annual Interest Rate</b>";
                }
                                if (!$error) {
                        $month_term              = $year_term * 12;
                        $down_payment            = $sale_price * ($down_percent / 100);
                        $annual_interest_rate    = $annual_interest_percent / 100;
                        $monthly_interest_rate   = $annual_interest_rate / 12;
                        $financing_price         = $sale_price - $down_payment;
                        $monthly_factor          = get_interest_factor($year_term, $monthly_interest_rate);
                        $monthly_payment         = $financing_price / $monthly_factor;
                }
        } else {
                if (!$sale_price)              { $sale_price              = $default_sale_price;              }
                if (!$annual_interest_percent) { $annual_interest_percent = $default_annual_interest_percent; }
                if (!$year_term)               { $year_term               = $default_year_term;               }
                if (!$down_percent)            { $down_percent            = $default_down_percent;            }
                if (!$show_progress)           { $show_progress           = $default_show_progress;           }
        }
                if ($error) {
                print("" . $error . "<br><br>n");
                $form_complete   = false;
        }
?>
">


                                                                        <b>Purchase & Financing Information</b>
                                Sale Price of Home:
                ">(In Dollars)
       
       
                Percentage Down:
                ">%
       
       
                Length of Mortgage:
                ">years
       
       
                Annual Interest Rate:
                ">%
       
       
                Explain Calculations:
                > Show me the calculations and amortization
       
       
                 
                <br>Start Over</a><br>"); } ?><br>
                // If the form has already been calculated, the $down_payment
        // and $monthly_payment variables will be figured out, so we
        // can show them in this table
        if ($form_complete && $monthly_payment) {
?>
                                        <b>Mortgage Payment Information</b>
                                                        Down Payment:
                        <b></b>
                                                        Amount Financed:
                        <b></b>
                                                        Monthly Payment:
                        <b></b><br>(Principal & Interest ONLY)
               
               
                        if ($down_percent
                                $pmi_per_month = 55 * ($financing_price / 100000);
                ?>
                                                                         
                                                                                        <br>
                                                Since you are putting LESS than 20% down, you will need to pay PMI (<a href="http://www.google.com/search?hl=en&q=private+mortgage+insurance">Private Mortgage Insurance</a>), which tends to be about $55 per month for every $100,000 financed (until you have paid off 20% of your loan). This could add  to your monthly payment.
                                       
                               
                               
                                        Monthly Payment:
                                        <b></b><br>(Principal & Interest, and PMI)
                               
               
                        }
                ?>
                                         
                                                        <br>
                                                                        $assessed_price           = ($sale_price * .85);
                                        $residential_yearly_tax  = ($assessed_price / 1000) * 14;
                                        $residential_monthly_tax = $residential_yearly_tax / 12;
                                       
                                        if ($pmi_per_month) {
                                                $pmi_text = "PMI and ";
                                        }
                                ?>
                                Residential (or Property) Taxes are a little harder to figure out... In Massachusetts, the average resedential tax rate seems to be around $14 per year for every $1,000 of your property's assessed value.
                                <br><br>
                                Let's say that your property's <i>assessed value</i> is 85% of what you actually paid for it - . This would mean that your yearly residential taxes will be around
                                This could add  to your monthly payment.
                       
               
               
                        TOTAL Monthly Payment:
                        <b></b><br>(including  residential tax)
               

        }
?>



        // This prints the calculation progress and
        // the instructions of HOW everything is figured
        // out
        if ($form_complete && $show_progress) {
                $step = 1;
?>
                <br><br>
                                                                        <b></b>
                                                                        The <b>down payment</b> = The price of the home multiplied by the percentage down divided by 100 (for 5% down becomes 5/100 or 0.05)<br><br>
                                        $ = $ X ( / 100)
                               
                       
                       
                                <b></b>
                                                                        The <b>interest rate</b> = The annual interest percentage divided by 100<br><br>
                                         = % / 100
                               
                       
                       
                               
                                        The <b>monthly factor</b> = The result of the following formula:
                               
                       
                       
                                <b></b>
                                                                        The <b>monthly interest rate</b> = The annual interest rate divided by 12 (for the 12 months in a year)<br><br>
                                         =  / 12
                               
                       
                       
                                <b></b>
                                                                        The <b>month term</b> of the loan in months = The number of years you've taken the loan out for times 12<br><br>
                                         Months =  Years X 12
                               
                       
                       
                                <b></b>
                                                                        The montly payment is figured out using the following formula:<br>
                                        Monthly Payment =  * ( / (1 - ((1 + )-())))
                                        <br><br>
                                        The <a href="#amortization">amortization</a> breaks down how much of your monthly payment goes towards the bank's interest, and how much goes into paying off the principal of your loan.
                               
                       
               
                <br>

                // Set some base variables
                $principal       = $financing_price;
                $current_month = 1;
                $current_year  = 1;
                // This basically, re-figures out the monthly payment, again.
                $power = -($month_term);
                $denom = pow((1 + $monthly_interest_rate), $power);
                $monthly_payment = $principal * ($monthly_interest_rate / (1 - $denom));
               
                print("<br><br><a></a>Amortization For Monthly Payment: <b>$" . number_format($monthly_payment, "2", ".", "thousands_sep") . "</b> over " . $year_term . " years<br>n");
                print("n");
               
                // This LEGEND will get reprinted every 12 months
                $legend  = "tn";
                $legend .= "tt<b>Month</b>n";
                $legend .= "tt<b>Interest Paid</b>n";
                $legend .= "tt<b>Principal Paid</b>n";
                $legend .= "tt<b>Remaing Balance</b>n";
                $legend .= "tn";
               
                echo $legend;
                               
                // Loop through and get the current month's payments for
                // the length of the loan
                while ($current_month
                        $interest_paid   = $principal * $monthly_interest_rate;
                        $principal_paid = $monthly_payment - $interest_paid;
                        $remaining_balance = $principal - $principal_paid;
                       
                        $this_year_interest_paid  = $this_year_interest_paid + $interest_paid;
                        $this_year_principal_paid = $this_year_principal_paid + $principal_paid;
                       
                        print("tn");
                        print("tt" . $current_month . "n");
                        print("tt$" . number_format($interest_paid, "2", ".", "thousands_sep") . "n");
                        print("tt$" . number_format($principal_paid, "2", ".", "thousands_sep") . "n");
                        print("tt$" . number_format($remaining_balance, "2", ".", "thousands_sep") . "n");
                        print("tn");
       
                        ($current_month % 12) ? $show_legend = FALSE : $show_legend = TRUE;
       
                        if ($show_legend) {
                                print("tn");
                                print("tt<b>Totals for year " . $current_year . "n");
                                print("tn");
                               
                                $total_spent_this_year = $this_year_interest_paid + $this_year_principal_paid;
                                print("tn");
                                print("tt n");
                                print("ttn");
                                print("tttYou will spend $" . number_format($total_spent_this_year, "2", ".", "thousands_sep") . " on your house in year " . $current_year . "<br>n");
                                print("ttt$" . number_format($this_year_interest_paid, "2", ".", "thousands_sep") . " will go towards INTEREST<br>n");
                                print("ttt$" . number_format($this_year_principal_paid, "2", ".", "thousands_sep") . " will go towards PRINCIPAL<br>n");
                                print("ttn");
                                print("tn");
       
                                print("tn");
                                print("tt <br><br>n");
                                print("tn");
                               
                                $current_year++;
                                $this_year_interest_paid  = 0;
                                $this_year_principal_paid = 0;
                               
                                if (($current_month + 6)
                                        echo $legend;
                                }
                        }
                                $principal = $remaining_balance;
                        $current_month++;
                }
                print("n");
        }
?>
<br><br>
This mortgage calculator can be used to figure out monthly payments of a home mortgage loan, based on the home's sale price, the term of the loan desired, buyer's down payment percentage, and the loan's interest rate. This calculator factors in PMI (Private Mortgage Insurance) for loans where less than 20% is put as a down payment. Also taken into consideration are the town property taxes, and their effect on the total monthly mortgage payment.<br><br>





        if ($print_footer) {
                print("n");
                print("n");
        }
?>






/*
        ///// mortgage_calculator.php /////
        Copyright (c) 2002 David Tufts  
        All rights reserved.
       
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions
        are met:
       
        *       Redistributions of source code must retain the above copyright
         notice, this list of conditions and the following disclaimer.
        *       Redistributions in binary form must reproduce the above
         copyright notice, this list of conditions and the following
         disclaimer in the documentation and/or other materials
         provided with the distribution.
        *       Neither the name of David Tufts nor the names of its
         contributors may be used to endorse or promote products
         derived from this software without specific prior
         written permission.
       
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
        CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
        INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
        MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
        BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
        EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
        TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
        DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
        ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        POSSIBILITY OF SUCH DAMAGE.
*/
?>
 
Do I need to do anything in the config.php? If i am way offbase please let me know.

Thanks Chris
 Quote

Status: offline

zipstart

Forum User
Chatty
Registered: 09/13/04
Posts: 60
Was that a copy/paste from somewhere? It looks really messy. Try grabbing it again.
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512

why do you have a PHP end tags all over the place, but no PHP open tags after the HTML? You may want to review that.

If you PHP is closed, it must be reopened befor adding more PHP code. etc...
 Quote

Status: offline

Remdotc

Forum User
Chatty
Registered: 06/12/02
Posts: 55
Your code is complex, just a thought but instead of trying to get this to work with static pages, why not create a php page, and wrap geeklog into it.

terms.php used something to the effect of
require_once('lib-common.php'); //
echo COM_siteHeader();
echo $display;
$display= "your stuff here";
echo COM_siteFooter();

 Quote

All times are EDT. The time is now 06:00 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content