Hi, I am a site owner with zero php experience. I have accidently deleted one letter from a header script and it caused my site to crash. I need desperate help. It shows Parse error: syntax error, unexpected T_STRING in /home/spark496/public_html/www.sourcetutoring.com/wp-content/themes/directorypress/header.php on line 152. Can any expert please help? This is the string below.

<?php

/* =============================================================================
   THIS FILE SHOULD NOT BE EDITED // UPDATED: 16TH MARCH 2012
   ========================================================================== */

global $PPT, $PPTDesign, $ThemeDesign, $pagenow, $userdata; get_currentuserinfo();

/* =============================================================================
   MAINTENANCE MODE // V7 // 16TH MARCH
   ========================================================================== */

if(get_option('maintenance_mode') == "yes" && ( !isset($_GET['redirect_to']) && $pagenow !="wp-login.php") ){ $msg = nl2br(stripslashes(get_option("maintenance_mode_message"))); if(strlen($msg)  < 1){ $msg ="Maintenance Mode On"; } die($msg);   }  

/* =============================================================================
   INITIALIZE PAGE ACTIONS AND GLOBALS // V7 // 16TH MARCH
   ========================================================================== */

premiumpress_action();

/* =============================================================================
   LOAD IN PAGE CONTENT // V7 // 16TH MARCH
   ========================================================================== */

$hookContent = premiumpress_pagecontent("header"); /* HOOK V7 */

if(strlen($hookContent) > 20 ){ // HOOK DISPLAYS CONTENT

    get_header();

    echo $hookContent;

    get_footer();

}elseif(file_exists(str_replace("functions/","",THEME_PATH)."/themes/".$GLOBALS['premiumpress']['theme']."/_header.php")){

    include(str_replace("functions/","",THEME_PATH)."/themes/".$GLOBALS['premiumpress']['theme'].'/_header.php');

}elseif(file_exists(str_replace("functions/","",THEME_PATH)."/template_".strtolower(PREMIUMPRESS_SYSTEM)."/_header.php")){

    include(str_replace("functions/","",THEME_PATH)."/template_".strtolower(PREMIUMPRESS_SYSTEM)."/_header.php");

}else{

/* =============================================================================
   LOAD IN PAGE DEFAULT DISPLAY // UPDATED: 25TH MARCH 2012
   ========================================================================== */ 

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<!--[if lte IE 8 ]><html lang="en" class="ie ie8"><![endif]-->
<!--[if IE 9 ]><html lang="en" class="ie"><![endif]-->
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />

<title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title> 

<?php wp_head(); ?>

</head> 

<body <?php ppt_body_class(); ?>>

<?php premiumpress_top(); /* HOOK */ ?>

    <div class="wrapper <?php $PPTDesign->CSS("ppt_layout_width"); ?>">

        <?php premiumpress_header_before(); /* HOOK */ ?>

           <?php function _bit_header_inside(){ /* HEADER WITH LOGO + BANNER */

            global $wpdb,$PPT;  

            return '<div id="header" class="full"><div class="w_960">

            <div class="f_half left" id="logo"> 

             <a href="'.$GLOBALS['bloginfo_url'].'/" title="'.get_bloginfo('name').'">

                <img src="'.$PPT->Logo(true).'" alt="'.get_bloginfo('name').'" />

             </a>

            </div>        

            <div class="left" id="banner"> 

             '.premiumpress_banner("top",true).'

            </div>

        </div> <!-- end header w_960 --> 

        <div class="clearfix"></div>

        </div> <!-- end header -->'; 

         } ?>

        <?php echo premiumpress_header_inside(_bit_header_inside()); /* HOOK  / FILTER  */ ?>             

        <?php premiumpress_header_after(); /* HOOK */ ?> 

        <?php premiumpress_menu_before(); /* HOOK */ ?>

        <?php function _bit_menu_inside(){ /* MENU BAR */

                global $wpdb,$PPT; $string='';

                $string .= '<div class="menu" id="menubar"> <div class="w_960">';

                if(has_nav_menu('PPT-CUSTOM-MENU-PAGES')){ $string .= wp_nav_menu( $GLOBALS['blog_custom_menu'] ); }else{ 

                $string .= '<ul> 

                    <li class="first"><a href="'.$GLOBALS['bloginfo_url'].'/" title="'.get_bloginfo('name').'">'.$PPT->_e(array('head','1')).'</a></li> 
                    '.premiumpress_pagelist().'                    
                    </ul>';                    

                }

                $string .= '</div><!-- end  menubar w_960 --> </div><!-- end menubar -->';

                return $string;

                }               
        ?>

         <?php echo premiumpress_menu_inside(_bit_menu_inside()); /* HOOK / FILTER */ ?> 

        <?php echo premiumpress_menu_after(); /* HOOK */ ?>        

        <?php if(isset($GLOBALS['ppt_layout_styles']['submenubar']) && isset($GLOBALS['ppt_layout_styles']['submenubar']['hide']) && $GLOBALS['ppt_layout_styles']['submenubar']['hide'] == 1){ ?>

        <?php }else{ ?>

        <?php premiumpress_submenu_before(); /* HOOK */ ?>

        <?php function _bit_submenu_inside(){ /*SUB MENU BAR */

            global $wpdb,$PPT, $userdata; get_currentuserinfo(); $string='';  

            $string .= '<div id="submenubar"><div class="w_960">';

            if(isset($GLOBALS['ppt_layout_styles']['submenubar']) && isset($GLOBALS['ppt_layout_styles']['submenubar']['search']) && $GLOBALS['ppt_layout_styles']['submenubar']['search'] == 1){

                $string .= '<div id="hpages"><ul>'.premiumpress_pagelist('submenu').'</ul></div>';

            }else{

                $string .= "<form method='get' action='".$GLOBALS['bloginfo_url']."/' name='searchBox' id='searchBox'>
                <input type='text' value='".$PPT->_e(array('head','2'))."' name='s' id='s' onfocus="this.value='';"  />";

                if(isset($GLOBALS['ppt_layout_styles']['submenubar']) && isset($GLOBALS['ppt_layout_styles']['submenubar']['hidecat']) && $GLOBALS['ppt_layout_styles']['submenubar']['hidecat'] == 1){ }else{ 
                    // BUILD CATEGORY DROP DOWN LIST
                    $catdata = premiumpress_categorylist(0,'toponly');
                    if(strlen($catdata) > 1){                   
                        $string .= '<select id="catsearch" name="cat"><option value="">&nbsp;</option>'.$catdata.'</select>';
                    }
                }

                $string .= '<div class="searchBtn left" onclick="document.searchBox.submit();"> &nbsp;</div>';

back space like 152 so it is with line 151 those are one whole line not two

<?PHP
// this is bad

 $string .= "<form method='get' action='".$GLOBALS['bloginfo_url']."/' name='searchBox' id='searchBox'>
<input type='text' value='".$PPT->_e(array('head','2'))."' name='s' id='s' onfocus="this.value='';" />";

// make it do this 

 $string .= "<form method='get' action='".$GLOBALS['bloginfo_url']."/' name='searchBox' id='searchBox'><input type='text' value='".$PPT->_e(array('head','2'))."' name='s' id='s' onfocus="this.value='';" />";

 ?>
Member Avatar for LastMitch

@ssfreaky

Hi, I am a site owner with zero php experience. I have accidently deleted one letter from a header script and it caused my site to crash. I need desperate help. It shows Parse error: syntax error, unexpected T_STRING in /home/spark496/public_html/www.sourcetutoring.com/wp-content/themes/directorypress/header.php on line 152. Can any expert please help? This is the string below.

First off, Why did you touch the code in the first place? Second of all you are using WordPress. The file that you provided is the header.php file?

I can tell you it's gonna be a bit hard to anyone to help you with this one because it's a header file on Wordpress and sadly to say that every WordPress template has it's own header file because of it's design.

Don't you have a backup for this template? Even you don't know PHP there should be a file that you can reupload the correct on and overwrite the current one.

You can try this:

From this:

  <input type='text' value='".$PPT->_e(array('head','2'))."' name='s' id='s' onfocus="this.value='';"  />";

To this:

  <input type='text' value='".$PPT->_e(array('head','2'))."' name='s' id='s' onfocus=\"this.value='';\" />";

I'm not sure it's gonna to work or not because I don't have the actaully WordPress template.

Thanks for the help. I tried restoring the original header.php file from backup and it still has this problem. I have since backed up my broken website and will try different methods today. If all else fails I can still recover to what I have right now.

I've tried the above methods and it does not seem to work. I think the file is originally corrupt because I realized even uploading the original file it still shows same problem.

I would ask my hosting company first, for any changes they made on your server. It might be some major upgrades or changed of server appliance...e.g. apache to nginx or something similar.

Member Avatar for LastMitch

I've tried the above methods and it does not seem to work. I think the file is originally corrupt because I realized even uploading the original file it still shows same problem.

If you already have the original files and you upload it overwrite the current one and still it didn't work. Then I think has to do with the permission on your host.

Try this first, I think notice something. You are missing a semicolon at the end of this statement:

$string .= "<form method='get' action='".$GLOBALS['bloginfo_url']."/' name='searchBox' id='searchBox'>

From this:

$string .= "<form method='get' action='".$GLOBALS['bloginfo_url']."/' name='searchBox' id='searchBox'>

Add a semicolon at the end of this statement:

$string .= "<form method='get' action='".$GLOBALS['bloginfo_url']."/' name='searchBox' id='searchBox'>;

If this doesn't work then talk to your host about the permission or I think you also might have to reinstalled the whole website.

Thank you for your help everyone. I managed to get someone from directorypress (wordpress theme plugin) to fix it. All your help are very much appreciated! The site is up now.

Happy Holidays!

The problem is on line 151, which is missing closing quote and trailing semicolon. It should probably read:

                $string .= "<form method='get' action='".$GLOBALS['bloginfo_url']."/' name='searchBox' id='searchBox'>";

eror

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.