Closed Thread
Results 1 to 4 of 4

Thread: PHP Parse Error

  1. #1
    crd06c is offline Newbie
    Join Date
    Jul 2009
    Posts
    1
    Rep Power
    0

    Unhappy PHP Parse Error

    I dont know where im going wrong.

    Can anyone help? This is my first time programming with PHP.

    Code:
    <body>
    <div id="container">
      <div id="mainContent">
        <h1> College Progress Calculator</h1>
    <?php

    $total_credits 
    120;
    $credits_earned $_POST["credits_earned"];
    $name $_POST["name"];
    $credits_remaining $total_credits $credits_earned;
    $percent_gone $credits_remaining $total_credits;

    echo 
    "<p>Hi " $name "!</p>";
    echo 
    "<p> Wow! You've already completed "$credits_earned " hours!</p>";
    echo 
    "<p> Only " credits_remaining " to go!</p>";
    echo 
    "<p> You have completed " $percent_gone " of your undergraduate degree.</p>";

    if (
    $percent_gone .3){
        echo 
    "<p>That Makes you a Freshman!</p>";
    }
    elseif (
    $percent_gone .6){
        echo 
    "<p>That makes you a Sophomore!</p>";
    }
    elseif (
    $percent_gone .9 
        echo 
    "<p>That makes you a Junior!</p>";
    }
    elseif (
    $percent_gone 1.0 
        echo 
    "<p>You are ready to GRADUATE!!!</p>";
    }

    ?>
    <p>&nbsp;</p>
    </div>
    </div>
    </body>
    </html>
    Im trying to create a calculator.
    Its for my programming course.
    Last edited by Jordan; 07-07-2009 at 12:00 PM. Reason: Added code tags

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Jordan Guest

    Re: PHP Parse Error

    Hey crd06c, welcome to the forum! I've added code tags to your post so that it is easier to see. If you post code again, please do the same.

    If you look at lines 24 and 27 you'll see that you forgot your ending ) on the condition. You also are making an assignment statement on line 27 instead of testing the condition. Use double ==

    Code:
    elseif ($percent_gone == 1.0) { 
    On line 15 you are missing the dollar sign from your variable credits_remaining. That should fix it up.

  4. #3
    sdavis2702's Avatar
    sdavis2702 is offline Learning Programmer
    Join Date
    Aug 2009
    Location
    Fort Sill, Oklahoma
    Posts
    95
    Rep Power
    0

    Re: PHP Parse Error

    Also, shouldn't line 11 be...

    Code:
    $percent_gone $credits_earned $total_credits
    Instead of...

    Code:
    $percent_gone $credits_remaining $total_credits
    ...to show what has been completed (percent_gone)? I copied and pasted this snippet and played around with it on my own computer and found that the calculator was giving more of an inversely proportional reading of credits completed to class year ratio. What I mean is, those who had earn more credits were freshmen and sophomores and those who earn less credits were juniors and seniors.

    Am I correct or still confused about how everything works? lol
    My Name is Sean and I like codes and stuff...
    NoobJunction.com | SuccessOnMyMind.com | ArmedForcesCarClub.com

  5. #4
    Jordan Guest

    Re: PHP Parse Error

    Sounds logically correct to me! (your correction, that is)

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. parse error in php
    By ravi951 in forum PHP Development
    Replies: 2
    Last Post: 09-20-2011, 10:30 PM
  2. Logic error in C hex parse program
    By indigo in forum C and C++
    Replies: 4
    Last Post: 09-14-2010, 09:44 AM
  3. [help]Parse error: syntax error, unexpected $end
    By kiddies in forum PHP Development
    Replies: 3
    Last Post: 07-18-2010, 02:58 PM
  4. Can't figure out this parse error
    By jackolantern in forum PHP Development
    Replies: 3
    Last Post: 08-09-2009, 03:02 PM
  5. parse error in php
    By amrosama in forum PHP Development
    Replies: 8
    Last Post: 05-03-2009, 01:07 PM

Tags for this Thread

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