Welcome to Virtual Pet List!

Wanting to join the rest of our members? Feel free to sign up today. Like what you see? Then join our community! You'll love it! Its free!

Sign Up
  1. virtual pet mascot

    Virtual Pets

    Welcome to the Virtual Pet list forum!
    We're a virtual pets and sim games community and we're the largest forum in our industry. We have a lot of virtual pet sites' owners and sim game owners that are quite active on our online community. Along with artists, writers and programmers that come here looking for work and games to work for. Our members who are artists sell art in our art marketplace and programmers are allowed to sell their scripts in the programming marketplace. We've been opened since 2011, however, we've owned our domain name since 2004 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 and directory of sim games have a lot of games listed that you can try out and possibly enjoy. If you're still curious about a game to play, you can check out some of our game reviews that were written by some of our great contributors and our interviews with respective virtual pet site owners, sim game owners, artists, writers and programmers that have done work in this industry as a whole.

  2. Check out our latest guide on how to grow your user base!
    Paladore - Boopets - Icepets - Corepets closed beta keys
    Virtual Pet Directory
    Are you looking for new virtual pet sites or sim games to play?
    Be sure to check out the latest changes to our rules.

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 />';
        }
    }
  2. Avalanche
    Offline

    Avalanche 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 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 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 />';
        }
    }

Share This Page