Parse error: syntax error

Discussion in 'PHP' started by peter_anderson, Nov 28, 2008.

  1. #1
    Hello

    Can any PHP guys tell me what part of the code is generating the error "
    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in index.template.php on line 181"?

    I've looked through every part of this code, but I cannot see what is wrong with it ;)

    Here is the code, begining on line 158

    (It's an SMF template)

    function template_body_above()
    {
       global $context, $settings, $options, $scripturl, $txt, $modSettings;
    
       echo '
    
    <!--- BEGIN MAIN SITE THINGY --->
    <DIV id=wrapper>
    <DIV id=top></DIV>
    <DIV id=banner></DIV>
    <DIV id=clientlogin>
    <br><br><!-- http://www.LiveZilla.net Chat Button Link Code --><a href="http://www.hostvoxeo.com/livezilla/livezilla.php?code=forums" target="_blank"><img src="http://www.hostvoxeo.com/livezilla/image.php?id=02" width="191" height="69" border="0" alt="LiveZilla Live Help" /></a><a href="http://www.livezilla.net"></a><!-- http://www.LiveZilla.net Chat Button Link Code --></DIV>
    
    <DIV id=nav><A href="http://www.hostvoxeo.com/index.html">Home</A> <A href="http://www.hostvoxeo.com/domains.html">Domains</A> <A 
    href="http://www.hostvoxeo.com/shared.html">Shared</A> <A href="http://www.hostvoxeo.com/reseller.html">Reseller</A> <A href="http://www.hostvoxeo.com/services.html">Services</A> <A 
    href="http://www.hostvoxeo.com/support.html">Support</A> <B><A href="http://www.hostvoxeo.com/order.html">Order</A></B> </DIV>
    
    <DIV id=welcome>
    
       // Display user name and time.
       if '($context['user']['is_logged'])'
          echo '
             <li id="name">' $txt['hello_member_ndt'], ' ' $context['user']['name'] '</li>';
       else
          echo '
             <li id="name">' $txt['hello_guest'], ' ' $txt['guest'] '</li>';
    
       echo '
    
       // If the user is logged in, display stuff like their name, new messages, etc.
       if ($context['user']['is_logged'])
       {
          echo '
                   <li><a href="', $scripturl, '?action=unread">', $txt['unread_since_visit'], '</a></li>
                   <li><a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a></li>';
    
          // Is the forum in maintenance mode?
          if ($context['in_maintenance'] && $context['user']['is_admin'])
             echo '
                   <li class="notice">', $txt['maintain_mode_on'], '</li>';
    
          // Are there any members waiting for approval?
          if (!empty($context['unapproved_members']))
             echo '
                   <li>', $context['unapproved_members'] == 1 ? $txt['approve_thereis'] : $txt['approve_thereare'], ' <a href="', $scripturl, '?action=admin;area=viewmembers;sa=browse;type=approve">', $context['unapproved_members'] == 1 ? $txt['approve_member'] : $context['unapproved_members'] . ' ' . $txt['approve_members'], '</a> ', $txt['approve_members_waiting'], '</li>';
    
          // Show the total time logged in?
          if (!empty($context['user']['total_time_logged_in']))
          {
             echo '
                   <li>', $txt['totalTimeLogged1'];
    
             // If days is just zero, don't bother to show it.
             if ($context['user']['total_time_logged_in']['days'] > 0)
                echo $context['user']['total_time_logged_in']['days'] . $txt['totalTimeLogged2'];
    
             // Same with hours - only show it if it's above zero.
             if ($context['user']['total_time_logged_in']['hours'] > 0)
                echo $context['user']['total_time_logged_in']['hours'] . $txt['totalTimeLogged3'];
    
             // But, let's always show minutes - Time wasted here: 0 minutes ;).
             echo $context['user']['total_time_logged_in']['minutes'], $txt['totalTimeLogged4'], '
                   </li>';
          }
    
          if (!empty($context['open_mod_reports']) && $context['show_open_reports'])
             echo '
                   <li><a href="', $scripturl, '?action=moderate;area=reports">', sprintf($txt['mod_reports_waiting'], $context['open_mod_reports']), '</a></li>';
          echo '
                </ul>';
       }
       // Otherwise they're a guest - this time ask them to either register or login - lazy bums...
       else
       {
          echo '
                <script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
                <form class="windowbg" id="guest_form" action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
                   ' , $txt['login_or_register'], '<br />
                   <input type="text" name="user" size="10" />
                   <input type="password" name="passwrd" size="10" />
                   <select name="cookielength">
                      <option value="60">', $txt['one_hour'], '</option>
                      <option value="1440">', $txt['one_day'], '</option>
                      <option value="10080">', $txt['one_week'], '</option>
                      <option value="43200">', $txt['one_month'], '</option>
                      <option value="-1" selected="selected">', $txt['forever'], '</option>
                   </select>
                   <input type="submit" value="', $txt['login'], '" /><br />
                   ', $txt['quick_login_dec'];
    
          if (!empty($modSettings['enableOpenID']))
             echo'
                   <br />
                   <input type="text" name="openid_url" id="openid_url" size="25" class="openid_login" />';
    
          echo '
                   <input type="hidden" name="hash_passwrd" value="" />
                </form>';
       }
    
       echo '
             </div>
          </div>
          <div id="news_section" class="titlebg2 clearfix"', empty($options['collapse_header']) ? '' : ' style="display: none;"', '>
             <form class="floatright" id="search_form" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
                <a href="', $scripturl, '?action=search;advanced" title="', $txt['search_advanced'], '"><img id="advsearch" src="'.$settings['images_url'].'/filter.gif" align="middle" alt="', $txt['search_advanced'], '" /></a>
                <input type="text" name="search" value="" style="width: 190px;" />&nbsp;
                <input type="submit" name="submit" value="', $txt['search'], '" style="width: 11ex;" />
                <input type="hidden" name="advanced" value="0" />';
    
       // Search within current topic?
       if (!empty($context['current_topic']))
          echo '
                <input type="hidden" name="topic" value="', $context['current_topic'], '" />';
          // If we're on a certain board, limit it to this board ;).
       elseif (!empty($context['current_board']))
          echo '
                <input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';
    
       echo '
             </form>';
    
       // Show a random news item? (or you could pick one from news_lines...)
       if (!empty($settings['enable_news']))
          echo '
             <div id="random_news"><h3>', $txt['news'], ':</h3><p>', $context['random_news_line'], '</p></div>';
    
       echo '
          </div>
       </div>';
    
    <!--- END MAIN SITE THINGY --->
    
    <div id="mainframe">
    
    <!--more stuff -->
    
       // Show the menu here, according to the menu sub template.
       template_menu();
    
       // Show the navigation tree.
       theme_linktree();
    
       // The main content should go here.
       echo '
       <div id="bodyarea">';
    }
    
    PHP:
     
    peter_anderson, Nov 28, 2008 IP
  2. Christian Little

    Christian Little Peon

    Messages:
    1,753
    Likes Received:
    80
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It's your echo statements, they're messed up.

    When using echo to display text/variables/etc you have to connect each segment with a .

    Furthermore, your code isn't even using the ' and " properly.

    For example, you have this:

    
    echo '
             <li id="name">' $txt['hello_member_ndt'], ' ' $context['user']['name'] '</li>';
    
    PHP:
    When it should look like this:

    
    echo "<li id=\"name\">" . $txt['hello_member_ndt'] . ", " . $context['user']['name'] . "</li>";
    
    PHP:
    That will fix your first echo statement, but all of them are broken. Use my example to fix all of your echo statements.
     
    Christian Little, Nov 28, 2008 IP
    peter_anderson likes this.
  3. misbah

    misbah Active Member

    Messages:
    265
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    68
    #3
    maybe this is what you want
    function template_body_above()
    {
       global $context, $settings, $options, $scripturl, $txt, $modSettings;
    
       echo '
    
    <!--- BEGIN MAIN SITE THINGY --->
    <DIV id=wrapper>
    <DIV id=top></DIV>
    <DIV id=banner></DIV>
    <DIV id=clientlogin>
    <br><br><!-- http://www.LiveZilla.net Chat Button Link Code --><a href="http://www.hostvoxeo.com/livezilla/livezilla.php?code=forums" target="_blank"><img src="http://www.hostvoxeo.com/livezilla/image.php?id=02" width="191" height="69" border="0" alt="LiveZilla Live Help" /></a><a href="http://www.livezilla.net"></a><!-- http://www.LiveZilla.net Chat Button Link Code --></DIV>
    
    <DIV id=nav><A href="http://www.hostvoxeo.com/index.html">Home</A> <A href="http://www.hostvoxeo.com/domains.html">Domains</A> <A
    href="http://www.hostvoxeo.com/shared.html">Shared</A> <A href="http://www.hostvoxeo.com/reseller.html">Reseller</A> <A href="http://www.hostvoxeo.com/services.html">Services</A> <A
    href="http://www.hostvoxeo.com/support.html">Support</A> <B><A href="http://www.hostvoxeo.com/order.html">Order</A></B> </DIV>
    
    <DIV id=welcome>';
    
       // Display user name and time.
       if ($context['user']['is_logged'])
          echo '
             <li id="name">', $txt['hello_member_ndt'], ' ', $context['user']['name'], '</li>';
       else
          echo '
             <li id="name">', $txt['hello_guest'], ' ', $txt['guest'], '</li>';
    
    
       // If the user is logged in, display stuff like their name, new messages, etc.
       if ($context['user']['is_logged'])
       {
          echo '
                   <li><a href="', $scripturl, '?action=unread">', $txt['unread_since_visit'], '</a></li>
                   <li><a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a></li>';
    
          // Is the forum in maintenance mode?
          if ($context['in_maintenance'] && $context['user']['is_admin'])
             echo '
                   <li class="notice">', $txt['maintain_mode_on'], '</li>';
    
          // Are there any members waiting for approval?
          if (!empty($context['unapproved_members']))
             echo '
                   <li>', $context['unapproved_members'] == 1 ? $txt['approve_thereis'] : $txt['approve_thereare'], ' <a href="', $scripturl, '?action=admin;area=viewmembers;sa=browse;type=approve">', $context['unapproved_members'] == 1 ? $txt['approve_member'] : $context['unapproved_members'] . ' ' . $txt['approve_members'], '</a> ', $txt['approve_members_waiting'], '</li>';
    
          // Show the total time logged in?
          if (!empty($context['user']['total_time_logged_in']))
          {
             echo '
                   <li>', $txt['totalTimeLogged1'];
    
             // If days is just zero, don't bother to show it.
             if ($context['user']['total_time_logged_in']['days'] > 0)
                echo $context['user']['total_time_logged_in']['days'] . $txt['totalTimeLogged2'];
    
             // Same with hours - only show it if it's above zero.
             if ($context['user']['total_time_logged_in']['hours'] > 0)
                echo $context['user']['total_time_logged_in']['hours'] . $txt['totalTimeLogged3'];
    
             // But, let's always show minutes - Time wasted here: 0 minutes ;).
             echo $context['user']['total_time_logged_in']['minutes'], $txt['totalTimeLogged4'], '
                   </li>';
          }
    
          if (!empty($context['open_mod_reports']) && $context['show_open_reports'])
             echo '
                   <li><a href="', $scripturl, '?action=moderate;area=reports">', sprintf($txt['mod_reports_waiting'], $context['open_mod_reports']), '</a></li>';
          echo '
                </ul>';
       }
       // Otherwise they're a guest - this time ask them to either register or login - lazy bums...
       else
       {
          echo '
                <script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
                <form class="windowbg" id="guest_form" action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
                   ' , $txt['login_or_register'], '<br />
                   <input type="text" name="user" size="10" />
                   <input type="password" name="passwrd" size="10" />
                   <select name="cookielength">
                      <option value="60">', $txt['one_hour'], '</option>
                      <option value="1440">', $txt['one_day'], '</option>
                      <option value="10080">', $txt['one_week'], '</option>
                      <option value="43200">', $txt['one_month'], '</option>
                      <option value="-1" selected="selected">', $txt['forever'], '</option>
                   </select>
                   <input type="submit" value="', $txt['login'], '" /><br />
                   ', $txt['quick_login_dec'];
    
          if (!empty($modSettings['enableOpenID']))
             echo'
                   <br />
                   <input type="text" name="openid_url" id="openid_url" size="25" class="openid_login" />';
    
          echo '
                   <input type="hidden" name="hash_passwrd" value="" />
                </form>';
       }
    
       echo '
             </div>
          </div>
          <div id="news_section" class="titlebg2 clearfix"', empty($options['collapse_header']) ? '' : ' style="display: none;"', '>
             <form class="floatright" id="search_form" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
                <a href="', $scripturl, '?action=search;advanced" title="', $txt['search_advanced'], '"><img id="advsearch" src="'.$settings['images_url'].'/filter.gif" align="middle" alt="', $txt['search_advanced'], '" /></a>
                <input type="text" name="search" value="" style="width: 190px;" />&nbsp;
                <input type="submit" name="submit" value="', $txt['search'], '" style="width: 11ex;" />
                <input type="hidden" name="advanced" value="0" />';
    
       // Search within current topic?
       if (!empty($context['current_topic']))
          echo '
                <input type="hidden" name="topic" value="', $context['current_topic'], '" />';
          // If we're on a certain board, limit it to this board ;).
       elseif (!empty($context['current_board']))
          echo '
                <input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';
    
       echo '
             </form>';
    
       // Show a random news item? (or you could pick one from news_lines...)
       if (!empty($settings['enable_news']))
          echo '
             <div id="random_news"><h3>', $txt['news'], ':</h3><p>', $context['random_news_line'], '</p></div>';
    
       echo '
          </div>
       </div>
    
    <!--- END MAIN SITE THINGY --->
    
    <div id="mainframe">
    
    <!--more stuff -->
    ';
       // Show the menu here, according to the menu sub template.
       template_menu();
    
       // Show the navigation tree.
       theme_linktree();
    
       // The main content should go here.
       echo '
       <div id="bodyarea">';
    }
    PHP:
     
    misbah, Nov 28, 2008 IP
    peter_anderson likes this.
  4. mrmaf

    mrmaf Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Normally this error come when u miss any semicolon ; in your code

    So please check your code and check all semi colons.

    It is 99% sure that lack of semicolon produce such error
     
    mrmaf, Nov 29, 2008 IP
  5. peter_anderson

    peter_anderson Notable Member

    Messages:
    3,382
    Likes Received:
    152
    Best Answers:
    0
    Trophy Points:
    240
    #5
    Thanks.

    Most of that code is all SMF, so it must be a problem with SMF.

    +rep to you ;)
     
    peter_anderson, Nov 29, 2008 IP
  6. adamhk

    adamhk Member

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #6
    
          echo '
             <li id="name">' $txt['hello_guest'], ' ' $txt['guest'] '</li>';
    PHP:
    replace with

    
          echo '
             <li id="name">' .$txt['hello_guest']. ' ' .$txt['guest']. '</li>';
    PHP:
    and would be better
     
    adamhk, Nov 29, 2008 IP
  7. misbah

    misbah Active Member

    Messages:
    265
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    68
    #7
    adamhk...
    I think, you can use ',' character or '.' for "echo".
     
    misbah, Nov 29, 2008 IP