Welcome to the Virtual Pet List Community

Wanting to join the rest of our members? Feel free to sign up today. It is completely free and one of the most positive communities on the web! Come and join the fun!

Join VPL Today!
  1. Virtual Pets

    Welcome to the Virtual Pet list forum!

    We're a Virtual Pets and Sim Games Community. We have a lot of Virtual Pet Sites Owners and Sim Games Owners that frequently visit, along with Artists, Writers and Programmers that come here looking for work and games to work for. Our Artists sell art in our Art Marketplace and Programmers are allowed to sell scripts in the Programming Marketplace. We've been opened since 2011 and since then we've grown and expanded quite nicely. What are you waiting for, why don't you join today?

    Our List of Virtual Pet Sites has a lot of Sim Games listed as well. You are more than welcome to check out our directory of sites and find a new game to play. If you're still curious about a game to play, you can check out some of our Game Reviews and Interviews with Coders, Artists, Writers and Game Owners of the industry.

Help...?

Discussion in 'Programming General' started by Moonlight, Jun 4, 2011.

  1. Moonlight
    Offline

    Moonlight Approved Artist Web Designer Approved Artist VPL Member

    Joined:
    Jan 28, 2011
    Messages:
    657
    Likes Received:
    11
    Trophy Points:
    28
    Location:
    Earth
    Anyway, I have a navigation system, and it gives me this error:

    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/a1728691/public_html/includes/functions.php on line 21

    The php code to show it is:

    PHP:
    <?php navigation(); ?>
    And the function [This is part of a "bigger" part of coding, thus there is no <?php and ?> tags as they come earlier/later on.]:

    PHP:
    function navigation()
    {
        if( 
    is_logged_in() ){
            echo 
    '<a href='index.php'>Home</a><br />';
            echo 
    '<a href='news.php'>News</a><br />';
            echo 
    '<a href='logout.php'>Logout</a><br />';    
        } else {
            echo 
    '<a href='index.php'>Home</a><br />';
            echo 
    '<a href='login.php'>Login</a><br />';
            echo 
    '<a href='signup.php'>Signup</a><br />';   
            echo 
    '<a href='news.php'>News</a><br />';
        }
    }
    join misticpets, support vpl
  2. Avalanche
    Offline

    Avalanche VPL Supporter VPL Supporter

    Joined:
    May 30, 2011
    Messages:
    428
    Likes Received:
    82
    Trophy Points:
    0
    Location:
    USA
    It may be possible using the single quotes in the link as well as in the echo is messing something up.

    PHP:
    function navigation() 

        if( 
    is_logged_in() ){ 
            echo 
    '<a href="index.php">Home</a><br />'
            echo 
    '<a href="news.php">News</a><br />'
            echo 
    '<a href="logout.php">Logout</a><br />';     
        } else { 
            echo 
    '<a href="index.php">Home</a><br />'
            echo 
    '<a href="login.php">Login</a><br />'
            echo 
    '<a href="signup.php">Signup</a><br />';    
            echo 
    '<a href="news.php">News</a><br />'
        } 
    }  
    Try using the double quotes instead? It won't mess up the HTML. Notice how using the double quotes changes the color of the links. I'm pretty sure that's what is causing your error.
  3. Noma
    Offline

    Noma New Member VPL Member

    Joined:
    May 24, 2011
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    NJ, USA
    @Avalanche's solution should solve the problem. The reason the links are changing color is your quotes are excluding the links from the original quotations, making them just part of the code and not part of the link reference.
    Last edited by a moderator: Oct 16, 2013
  4. Avalanche
    Offline

    Avalanche VPL Supporter VPL Supporter

    Joined:
    May 30, 2011
    Messages:
    428
    Likes Received:
    82
    Trophy Points:
    0
    Location:
    USA
    @Noma - yeah that's the more official way of saying it. XD But then when PHP doesn't detect a ';' or ',' after it thinks the echo statement has ended it sends and error.
    Last edited by a moderator: Oct 16, 2013
  5. Noma
    Offline

    Noma New Member VPL Member

    Joined:
    May 24, 2011
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    NJ, USA
    I wasn't correcting you, just agreeing =]
  6. Moonlight
    Offline

    Moonlight Approved Artist Web Designer Approved Artist VPL Member

    Joined:
    Jan 28, 2011
    Messages:
    657
    Likes Received:
    11
    Trophy Points:
    28
    Location:
    Earth
    Thank you! It works.
  7. Avalanche
    Offline

    Avalanche VPL Supporter VPL Supporter

    Joined:
    May 30, 2011
    Messages:
    428
    Likes Received:
    82
    Trophy Points:
    0
    Location:
    USA
    Last edited by a moderator: Oct 16, 2013
  8. jibbles
    Offline

    jibbles New Member VPL Member

    Joined:
    May 10, 2011
    Messages:
    150
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    UK
    An alternative solution is to escape the single quotes. By putting a backslash before the quote mark it tells php that this isn't the end of the string. The backslash itself won't be echo'd.
    PHP:
    function navigation()
    {
        if( 
    is_logged_in() ){
            echo 
    '<a href=\'index.php\'>Home</a><br />';
            echo 
    '<a href=\'news.php\'>News</a><br />';
            echo 
    '<a href=\'logout.php\'>Logout</a><br />';    
        } else {
            echo 
    '<a href=\'index.php\'>Home</a><br />';
            echo 
    '<a href=\'login.php\'>Login</a><br />';
            echo 
    '<a href=\'signup.php\'>Signup</a><br />';   
            echo 
    '<a href=\'news.php\'>News</a><br />';
        }
    }
Similar Threads
Forum Title Date
Programming General Can Someone Help Me With Js? Apr 9, 2014
Programming General Css Help? Apr 3, 2014
Programming General Imagemagick Help Apr 3, 2014
Programming General Is This Code Going To Be Any Help? Apr 3, 2014
Programming General Sql Query Help Jan 18, 2014
Programming General Help Me With Code! (please) Jan 2, 2014
Programming General Rpg Help Please Dec 10, 2013
Programming General Ajax Quick Help Nov 9, 2013
Programming General Need Help With Paypal Pay Now Button Integration Nov 8, 2013
Programming General I Need Help With Markings And Mutations Oct 25, 2013
Programming General Moving mass items help Oct 5, 2013
Programming General php/ajax/jquery help? Sep 27, 2013
Programming General Complex if statments? help? Sep 19, 2013
Programming General Help with CSS Pixy rollovers? Aug 14, 2013
Programming General Database Set-Up Help? Jun 2, 2013

Share This Page