+ Reply to Thread
Results 1 to 4 of 4

Thread: PHP Parse Error

  1. #1
    Newbie crd06c is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    1

    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 02:00 PM. Reason: Added code tags

  2. #2
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,556
    Blog Entries
    97

    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.

  3. #3
    Learning Programmer sdavis2702 is an unknown quantity at this point sdavis2702's Avatar
    Join Date
    Aug 2009
    Location
    Fort Sill, Oklahoma
    Age
    25
    Posts
    95

    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

  4. #4
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,556
    Blog Entries
    97

    Re: PHP Parse Error

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

+ Reply to 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 amrosama in forum PHP Forum
    Replies: 8
    Last Post: 05-03-2009, 03:07 PM
  2. need urgent help finding parce error!!!
    By siren in forum C and C++
    Replies: 3
    Last Post: 09-13-2007, 09:45 AM
  3. Php - CGI Error
    By thesquirrel16 in forum General Programming
    Replies: 1
    Last Post: 05-19-2007, 05:09 PM
  4. can someone help me with my c librarys?
    By bobwrit in forum C and C++
    Replies: 4
    Last Post: 04-27-2007, 06:19 PM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

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