Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    1,963
    Thanks
    0
    Thanked 0 Times in 0 Posts

    if else parse error

    I'm finally taking the plunge into php, but I've come across this error that won't go away... I've searched, I've read my only printed resource (Sam's PHP in 24 hrs) and I'm stuck.
    PHP Code:
    //this is up top
    <? php $page $_GET['cat']; ?>

    //then this down further
      <? php if ( $page == "css" ) {
    print 
    "Cascading Style Sheets";
    } else if ( 
    $page == "code" ) {
    print 
    "Code"
    } else { print 
    "Everyone's Web" ?>
    It's seriously simple, but I keep getting a parse error on the first line of the second part. I've tried different quoting (single vs. double) and a few other wild guesses, but to no avail.

    Baffled by simplicity,
    Andrew.

    I take no responsibility for the above nonsense.


    Left Justified

  • #2
    New Coder
    Join Date
    Apr 2004
    Location
    Texas
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    try this

    2 things,
    there shouldn't be a space in <? php, it should be <?php
    second thing, there was no semicolon on the last line.

    try this
    PHP Code:
    <?php $page $_GET['cat'];?>

    <?php if ( $page == "css" ) {
    print 
    "Cascading Style Sheets";
    } else if ( 
    $page == "code" ) {
    print 
    "Code";
    } else { print 
    "Everyone's Web"; } ?>
    Jason B

  • #3
    Senior Coder
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    1,963
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nice one bruva

    I take no responsibility for the above nonsense.


    Left Justified


  •  

    Posting Permissions

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