Support » Fixing WordPress » Parse Error: Syntax Error when index.php copied to root

  • Resolved SomethingWonderful

    (@somethingwonderful)


    I’m having a nightmare.

    When I copy the index.php file (and the htaccess) to the root directory I’m getting the error message below?

    “”Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE in /home/*****/public_html/index.php on line 17″”

    I’ve created many wordpress sites and never come across this problem before. It’s happening on every new install.

    No plug-ins, no custom themes, happens on the cleanest new installation. My hosting company also have no idea what could be causing the problem.

    Has anyone else had this problem, or can anyone enlighten me with suggestions?

    Many thanks,

    SW

Viewing 15 replies - 1 through 15 (of 27 total)
  • esmi

    (@esmi)

    Forum Moderator

    What is in this index.php file?

    SomethingWonderful

    (@somethingwonderful)

    It’s the standard wordpress index file that loads the wp-blog-header.php…

    That’s what is so odd..

    esmi

    (@esmi)

    Forum Moderator

    Can we see it?

    SomethingWonderful

    (@somethingwonderful)

    /**
    * Front to the WordPress application. This file doesn’t do anything, but loads
    * wp-blog-header.php which does and tells WordPress to load the theme.
    *
    * @package WordPress
    */

    /**
    * Tells WordPress to load the WordPress theme and output it.
    *
    * @var bool
    */
    ‘define(‘WP_USE_THEMES’, true);

    /** Loads the WordPress Environment and Template */
    require(‘./wp-blog-header.php’);’

    SomethingWonderful

    (@somethingwonderful)

    I’m adding the wordpress directory as below… But not calling it “wordpress” obv…

    ‘define(‘WP_USE_THEMES’, true);

    /** Loads the WordPress Environment and Template */
    require(‘./wordpress/wp-blog-header.php’);

    SomethingWonderful

    (@somethingwonderful)

    Actually apologies…

    it’s the new wordpress index.php as below.

    <?php
    /**
     * Front to the WordPress application. This file doesn't do anything, but loads
     * wp-blog-header.php which does and tells WordPress to load the theme.
     *
     * @package WordPress
     */
    
    /**
     * Tells WordPress to load the WordPress theme and output it.
     *
     * @var bool
     */
    'define('WP_USE_THEMES', true);
    
    /** Loads the WordPress Environment and Template */
    require( dirname( __FILE__ ) . '/wp-blog-header.php' );

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    Moderator keesiemeijer

    (@keesiemeijer)

    moderator

    Did you add the single quotes here

    'define(... rest of code

    and here:

    require(...);'

    SomethingWonderful

    (@somethingwonderful)

    Ahh no, just wanted to separate the code.

    esmi

    (@esmi)

    Forum Moderator

    Try:

    <?php
    /**
     * Front to the WordPress application. This file doesn't do anything, but loads
     * wp-blog-header.php which does and tells WordPress to load the theme.
     *
     * @package WordPress
     */
    
    /**
     * Tells WordPress to load the WordPress theme and output it.
     *
     * @var bool
     */
    define('WP_USE_THEMES', true);
    
    /** Loads the WordPress Environment and Template */
    require( dirname( __FILE__ ) . '/path_to_wordpress_here/wp-blog-header.php' );

    substituting path_to_wordpress_here appropriately.

    SomethingWonderful

    (@somethingwonderful)

    Hi Esmi,

    That’s no different to what I have been doing? My apologies but I used the older WP index.php in my first answer to you then corrected a couple of posts down.

    I have spoken to one other person who had this problem, using a different hosting company to me. He couldn’t find an answer either. But I can’t believe we’re the only two?

    The only solution for me at the moment is to install wordpress in the root directory but that really isn’t ideal…

    SW

    esmi

    (@esmi)

    Forum Moderator

    That’s no different to what I have been doing?

    The code I gave was pulled from a working install, so it might be worth trying it in case your copy has non-visible characters at the end of the file.

    I can’t believe we’re the only two?

    Sorry but I can. I’ve used this technique many times without any problems.

    Moderator keesiemeijer

    (@keesiemeijer)

    moderator

    SomethingWonderful

    (@somethingwonderful)

    Hi again Esmi,

    Have tried copying the file directly from a working site, no luck. Have also used Installatron to install WordPress files and DB and same problem.

    I’ve also used exactly the same technique on over 100 WordPress sites in the last 3 years.

    I’m asking the hosting company to look into it but they are denying any issue their end. I think I’m going to have to go to a new host but that is such a nuisance.

    So frustrating…

    SW

    SomethingWonderful

    (@somethingwonderful)

    Hi keesiemeijer,

    TextEditor on Mac, but like I say, I’ve tried copying the index file from other working sites to no avail.

    I think it might have something to do with

    require( dirname( __FILE__ ) . ‘/path_to_wordpress_here/wp-blog-header.php’ );

    which has just changed in the new version from

    require(‘./wordpress/wp-blog-header.php’);

    Hence the message

    T_ENCAPSED_AND_WHITESPACE

    SW

    Moderator keesiemeijer

    (@keesiemeijer)

    moderator

    I don’t think that’s the problem. If the path was wrong you would get this error: failed to open stream: No such file or directory.

    Not sure what’s going on here but I would download a fresh copy of WordPress and edit the index.php with another texteditor (just for testing):
    http://codex.wordpress.org/Editing_Files#Using_Text_Editors

Viewing 15 replies - 1 through 15 (of 27 total)
  • The topic ‘Parse Error: Syntax Error when index.php copied to root’ is closed to new replies.