Forums

Coder help needed (11 posts)

  1. pezastic
    Member
    Posted 7 years ago #

    I'm trying to figure out a global post-to-post navigational scheme and I haven't a clue what I'm doing. I need help with a code snippet. I have it right below the content div in my index.php file. I'm getting a parse error, unexpected on the last '}':

    if (basename(__FILE__) == 'index.php' && $_SERVER['QUERY_STRING'] =='') {
    previous_post('%','<img src="http://www.bbiverson.com/images/buttons/previous.jpg" alt="Read Previous Entry" align="middle" />Previous Entry', 'no', 'no', 1, '')
    } else {
    previous_post('%','<img src="http://www.bbiverson.com/images/buttons/previous.jpg" alt="Read Previous Entry" align="middle" />Previous Entry', 'no', 'no', 1, '') &nbsp; ?>
    ">Latest Entry &nbsp;
    <?php next_post('%','Next Entry<img src="http://www.bbiverson.com/images/buttons/next.jpg" alt="Read Next Entry" align="middle" />','no','no',1,'');
    }

    Can someone help me?

  2. ringmaster
    Member
    Posted 7 years ago #

    What are those " amp;nbsp;"s meant to be? The forum has mangled your code somewhat.
    And your error is "Unexpected }"?

  3. Cypher
    Member
    Posted 7 years ago #

    It looks like you're missing a closing paranthesis for your primary IF statement. So put a close ')' after '$_SERVER['QUERY_STRING'] =='')' and see if your error goes away.
    Regards

  4. Root
    Member
    Posted 7 years ago #

    You wanted what ?

  5. pezastic
    Member
    Posted 7 years ago #

    The previous, latest, and next links were running together, so I put in a couple non-breaking spaces. Anyway, they aren't the problem. I don't know what is, but they aren't. :-)

  6. Cypher
    Member
    Posted 7 years ago #

    Actually, what I meant was:
    if (basename(__FILE__) == 'index.php') && ($_SERVER['QUERY_STRING']) == '')) {
    Notice the ')' after the first check. With this code I don't get any errors.
    Regards

  7. Cypher
    Member
    Posted 7 years ago #

    Send me an email and I'll help you through this.
    Regards

  8. coffee2code
    WordPress & Plugin Dev
    Posted 7 years ago #

    To my eye it looks like the parentheses are unbalanced for the if()'s conditions. Perhaps try:
    if ((basename (__FILE__) == 'index.php') && ($_SERVER['QUERY_STRING'] == '')) {
    I haven't look at this any deeper than that.

  9. pezastic
    Member
    Posted 7 years ago #

    Nope that didn't solve the error problem, either. :-(

  10. coffee2code
    WordPress & Plugin Dev
    Posted 7 years ago #

    Do you close out the php tag at the end of your snippet, like so:
    <?php next_post('%','Next Entry<img src="http://www.bbiverson.com/images/buttons/next.jpg" alt="Read Next Entry" align="middle" />','no','no',1,'');
    } ?>

  11. pezastic
    Member
    Posted 7 years ago #

    That worked wonderfully! You're a godsend.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.