Welcome to Virtual Pet List

Would you like to become a member of the largest and most successful virtual pets & sim games community on the internet today? We've been opened since 2011 and we're getting very close to having over 9,000 members .who are fans of pet games and sims just like you are. So if playing a pet site or a sim game interests you, then we'd love to have you become a member of our flourishing online community.

  1. An upcoming virtual pet site that's owned by one of our moderators, Pepper-headAn upcoming virtual pet site that's owned by one of our moderators, Pepper-head sim game where you can breed your very own cats Kaylune, a virtual pet site Grophland.com : Breed virtual pets, Play, Explore
    VigLink badge
    Novilar

    Find New Virtual Pet Sites, Sim Games or Role Playing games to Play.
    Help vpl reach 10k users by Promoting us - advertise on vpl
    : Virtual Pets Blog - The Admin Effect - Browser games


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

    Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.
  • Like VPL on Facebook!

  • Support VPL

    We have to face that the site doesn't run for free sadly. If it did, we would be all set but unfortunately the costs are getting higher and higher as we grow. We offer members a Supporter premium usergroup. If you donate to VPL you are joined to this group and you get many perks that members do not get.

    Donate to VPL!