Virtual pets and Sim games community

Would you like to become a member of the most successful virtual pets and sim games community on the internet today? We've been opened since 2011 and since then, we've been providing web game developers, artists, players and writers with the most relevant, up to date, quality and in depth content covering the entire online browser based games industry. So, if you virtual pet games, game development or online sims, our forum is perfect for you. Our sneak peeks forum is designed for new owners to showchase their upcoming in dev games.

Discuss online pet game management or developing a sim game.

  1. An upcoming virtual pet site that's owned by one of our moderators, Pepper-headIn icey them pet game Kaylune, a virtual pet site Breed online pet
    VigLink badge
    Novilar opening up for beta September 16 - Beastkeeper
    breed horses on this very active sim game

    Browse our Online Games Directory
    Promote VPL - advertise here
    Admin and webmasters community - Browser games
    $100 posting contest



Help...?

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

  1. 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 />';
        }
    }
     
    Your banner/button can be located here for an entire month or year, please see our advertising on virtualpetlist thread for more information.

  2. 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. @AvalancheAvalanche'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.
     
    #3 Noma, Jun 5, 2011
    Last edited by a moderator: Oct 16, 2013
  4. @NomaNoma - 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.
     
    #4 Avalanche, Jun 5, 2011
    Last edited by a moderator: Oct 16, 2013
  5. I wasn't correcting you, just agreeing =]
     
  6. Thank you! It works.
     
  7. #7 Avalanche, Jun 5, 2011
    Last edited by a moderator: Oct 16, 2013
  8. 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 />';
        }
    }
     

Share This Page

  • About VPL

    We are an online community of passionate artists, writers, programmers and general users who have a vested interest in virtual pet games & sim games. Everyone on our forum are from different backgrounds and yet we group together with one goal, to ensure our pet games and sims forum is one of the best!
  • Like VPL on Facebook!

  • Support VPL

    If you love our community and you'd like to help us cover our monthly costs, we'd greatly appreciate it if you could help us out by supporting us! If you can't donate, we totally understand. You can also support us by using our social media sharing buttons or by writing about us on other sites.

    Donate to VPL!