Results 1 to 5 of 5

Thread: unexpected T_ELSE problem! please help

  1. #1
    Join Date
    Oct 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default unexpected T_ELSE problem! please help

    hello, im pretty new to php and i have to write a little program for my computer class but no matter what i do i get the error. help much appreciated the unexpected error is on like 14, 20, 26.

    PHP Code:
    <?php

       $loanamount 
    0.0;
       
    $deposit 0.0;
       
    $totalcost 0.0;
       
       
    printf("\nEnter Desired Loan Amount: ");
       
    fscanf(STDIN"%f"$loanamount);

       if(
    $loanamount && $loanamount 25000 );
           {
        
    $deposit $loanamount .05;                  
           }
           else
           {
               if(
    $loanamount >= 25000 && $loanamount 50000 );
               {
             
    $deposit = ($loanamount 25000) * .10;    
            }
           else
               {
                   if(
    $loanamount    >= 50000 && $loanamount <= 100000);
                   {        
                
    $deposit = ($loanamount 50000) * .25;        
                }
                else            
                {
                    if (
    $loanamount <= || $loanamount 100000);
                    {
                    
    printf("\n The amount requested is beyond the acceptable value. Please enter an amount between $0 and $100000");
                    }
                }
            }  
        }    
                  
          
    printf("\nYour deposit will be %.2f",$deposit);
          
    $totalcost $loanamount $deposit;
          
    printf("\nYour total loan cost will be %.2f",$totalcost);
    ?>

  2. #2
    Join Date
    Oct 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hi Legato213

    you´r adding semicolon ';' after your IF statements.

  3. #3
    Join Date
    Jan 2006
    Location
    Ft. Smith, AR
    Posts
    795
    Thanks
    57
    Thanked 129 Times in 116 Posts

    Default

    Try using this instead...


    PHP Code:
    <?php

       $loanamount 
    0.0;
       
    $deposit 0.0;
       
    $totalcost 0.0;
       
       
    printf("\nEnter Desired Loan Amount: ");
       
    fscanf(STDIN"%f"$loanamount);

       if(
    $loanamount && $loanamount 25000 )
           {
       
    $deposit $loanamount .05;                  
           }
           else
           {
               if(
    $loanamount >= 25000 && $loanamount 50000 )
               {
             
    $deposit = ($loanamount 25000) * .10;    
            }
           else
               {
                   if(
    $loanamount    >= 50000 && $loanamount <= 100000)
                   {        
               
    $deposit = ($loanamount 50000) * .25;        
                }
                else            
                {
                    if (
    $loanamount <= || $loanamount 100000)
                    {
                    
    printf("\n The amount requested is beyond the acceptable value. Please enter an amount between $0 and $100000");
                    }
                }
            }  
        }    
                  
          
    printf("\nYour deposit will be %.2f",$deposit);
          
    $totalcost $loanamount $deposit;
          
    printf("\nYour total loan cost will be %.2f",$totalcost);
    ?>
    Edit: Nevermind, the one above me beat me to the punch. LOL
    --------------------------------------------------
    Reviews, Interviews, Tutorials, and STUFF
    --------------------------------------------------
    Home of the SexyBookmarks WordPress plugin

  4. The Following User Says Thank You to TheJoshMan For This Useful Post:

    jimbob79 (10-14-2008)

  5. #4
    Join Date
    Oct 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    lol thank you guys for you help! what a silly mistake

  6. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Additionally, your code formatting is very weird. It becomes a lot more readable if you format it nicely and remove all the excess braces that are cluttering it up:
    Code:
    <?php
        $loanamount = 0.0;
        $deposit = 0.0;
        $totalcost = 0.0;
    
        printf("\nEnter Desired Loan Amount: ");
        fscanf(STDIN, "%f", $loanamount);
    
        if ($loanamount > 0 && $loanamount < 25000)
            $deposit = $loanamount * .05;                  
        else if ($loanamount >= 25000 && $loanamount < 50000)
            $deposit = ($loanamount - 25000) * .10;
        else if($loanamount >= 50000 && $loanamount <= 100000)
            $deposit = ($loanamount - 50000) * .25;
        else if ($loanamount <= 0 || $loanamount > 100000)
            printf("\n The amount requested is beyond the acceptable value. Please enter an amount between $0 and $100000");
    
        printf("\nYour deposit will be %.2f\n", $deposit);
        $totalcost = $loanamount + $deposit;
        printf("Your total loan cost will be %.2f\n", $totalcost);
    ?>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •