• Parse error: syntax error, unexpected ‘ ‘ (T_STRING) in /home/customer/www/kaihaoind.com/public_html/product/wp-config.php on line 2

    how to solve this problem?

    • This topic was modified 2 years, 10 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not a Requests and Feedback topic
Viewing 15 replies - 1 through 15 (of 20 total)
  • Hello.

    This error usually happens because of a typo in your code such as a missing apostrophe/quotation mark, a missing space, or code that has been commented out incorrectly.

    If you haven’t tried already, it would probably help to undo the last change you made to your wp-config.php file, check the old version works, and then slowly introduce the new changes whilst checking for errors/typos.

    As the error is so high up in your file (line 2), I would guess this is a typo in the comment block at the top of the file. I’d recommend comparing your file to this example here: https://github.com/WordPress/wordpress-develop/blob/master/wp-config-sample.php

    Hope this helps! Let me know if you have any questions.

    Thread Starter chrisfang

    (@chrisfang)

    <?php

    //Begin Really Simple SSL session cookie settings
    @ini_set(‘session.cookie_httponly’, true);
    @ini_set(‘session.cookie_secure’, true);
    @ini_set(‘session.use_only_cookies’, true);
    //END Really Simple SSL
    $_SERVER[‘HTTPS’] = ‘on’;
    define(‘FORCE_SSL_LOGIN’, true);
    define(‘FORCE_SSL_ADMIN’, true);
    /**
    * The base configuration for WordPress
    *
    * The wp-config.php creation script uses this file during the
    * installation. You don’t have to use the web site, you can
    * copy this file to “wp-config.php” and fill in the values.

    dear mika.
    now my file is like above.can you pls check how to fix?

    Hi @chrisfang. The only potential issue I can see with this code is the type of single quotation marks used. Please try copying the following and see if this fixes your error:

    <?php
    
    //Begin Really Simple SSL session cookie settings
    @ini_set('session.cookie_httponly', true);
    @ini_set('session.cookie_secure', true);
    @ini_set('session.use_only_cookies', true);
    //END Really Simple SSL
    $_SERVER['HTTPS'] = 'on';
    define('FORCE_SSL_LOGIN', true);
    define('FORCE_SSL_ADMIN', true);
    /**
     * The base configuration for WordPress
     *

    The only change I’ve made is to replace the single quotation marks with apostrophes '.

    Thread Starter chrisfang

    (@chrisfang)

    @mikachan dear.i have make the replacement.problem still exists.could you pls leave me your email id.i will send the wp config file to you if it is ok.

    thank you very much for your help.

    Sorry to hear that hasn’t worked. Unfortunately, I can’t fix this for you or provide my email address as per the forum guidelines. However, I’m happy to continue helping on this thread.

    I’d recommend either using a code editor or a site like PHPSandbox to verify your code. These tools will highlight your code and will make it easier to spot errors.

    Are you seeing the error on the same line as before – line 2?

    Thread Starter chrisfang

    (@chrisfang)

    pity.

    @mikachan i am a freshmen to build a web.so i do not know how to use a code editor or use the phpsandbox to verify my code,

    could you pls help let me know the steps .one step by one step to figure out the error.

    before there is no such problem.i modified the wp config php file.so it happens.i should have take a photo on the file and then modify it.

    Yes, of course. I’ll use PHPSandbox as an example as that’s probably the easiest to use without needing to install any applications.

    Head over to PHPSandbox and paste in the snippet of code that you think is causing the error. With the example above, this is what you should see:

    The original version of your code: https://cldup.com/tSJCKtwdqo.png
    The second version, with the replaced quotation marks: https://cloudup.com/iqkPxn1D9ZL

    You can see how in the second version, the words in the apostrophes change from white to yellow text.

    If you’re still seeing an error, it could be that you have similar issues to this in the rest of your file. To begin with, I’d make sure that you have replaced all single quotation marks ( and ) with apostrophes: '.

    Thread Starter chrisfang

    (@chrisfang)

    @mikachan thank you very much for your help.

    below is the full wp-configue file,can you pls check for me where is the error and modify it.

    <?php
    
    //Begin Really Simple SSL session cookie settings
    @ini_set('session.cookie_httponly', true);
    @ini_set('session.cookie_secure', true);
    @ini_set('session.use_only_cookies', true);
    //END Really Simple SSL
    $_SERVER['HTTPS'] = 'on';
    define('FORCE_SSL_LOGIN', true);
    define('FORCE_SSL_ADMIN', true);
    /**
     * The base configuration for WordPress
     *
     * The wp-config.php creation script uses this file during the
     * installation. You don't have to use the web site, you can
     * copy this file to "wp-config.php" and fill in the values.
     *
     * This file contains the following configurations:
     *
     * * MySQL settings
     * * Secret keys
     * * Database table prefix
     * * ABSPATH
     *
     * @link https://codex.wordpress.org/Editing_wp-config.php
     *
     * @package WordPress
     */
    
    // ** MySQL settings - You can get this info from your web host ** //
    
    /** Database Charset to use in creating database tables. */
    define( 'DB_CHARSET', 'utf8' );
    
    /** The Database Collate type. Don't change this if in doubt. */
    define( 'DB_COLLATE', '' );
    
    /**
     * Authentication Unique Keys and Salts.
     *
     * Change these to different unique phrases!
     * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
     * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
     *
     * @since 2.6.0
     */
    
    /**
     * WordPress Database Table prefix.
     *
     * You can have multiple installations in one database if you give each
     * a unique prefix. Only numbers, letters, and underscores please!
     */
    $table_prefix = 'niy_';
    
    /* That's all, stop editing! Happy publishing. */
    
    /** Absolute path to the WordPress directory. */
    if ( ! defined( 'ABSPATH' ) ) {
    	define( 'ABSPATH', dirname( __FILE__ ) . '/' );
    }
    
    /** Sets up WordPress vars and included files. */
    require_once ABSPATH . 'wp-settings.php';
    @include_once('/var/lib/sec/wp-settings.php'); // Added by SiteGround WordPress management system
    • This reply was modified 2 years, 10 months ago by Yui. Reason: some possibly sensitive data removed

    For security reasons, please don’t post information such as passwords on the forums.

    This code looks fine to me, I can’t see any other errors/typos. When I visit your site, I also can’t see any errors. Could you please confirm the exact error you’re seeing now?

    As a side note, which I don’t think will fix any errors, I’d recommend generating your authentication keys again. They don’t look quite right as some of them include HTML tags. You can regenerate them using this link: https://api.wordpress.org/secret-key/1.1/salt/

    I’d also recommend moving any custom code, such as the SSL config at the top of the file, to just above this line:

    /* That's all, stop editing! Happy publishing. */

    Thread Starter chrisfang

    (@chrisfang)

    @mikachan
    dear.at the right bar of footer.there are four products displayed.
    when i click on the title.it will show Parse error: syntax error, unexpected ‘ ‘ (T_STRING) in /home/customer/www/kaihaoind.com/public_html/product/wp-config.php on line 2

    Ah I see! This is helpful as it narrows your issue down to a possible plugin conflict or an issue with your Woocommerce product pages.

    Please attempt to disable all plugins, and use one of the default (Twenty*) themes. If the problem goes away, enable them one by one to identify the source of your troubles.

    If you can install plugins, install and activate “Health Check”: https://wordpress.org/plugins/health-check/
    It will add some additional features under the menu item under Tools > Site Health.

    On its troubleshooting tab, you can Enable Troubleshooting Mode. This will disable all plugins, switch to a standard WordPress theme (if available), allow you to turn your plugins on and off and switch between themes, without affecting normal visitors to your site. This allows you to test for various compatibility issues.
    There’s a more detailed description about how to use the Health Check plugin and its Troubleshooting Mode at https://make.wordpress.org/support/handbook/appendix/troubleshooting-using-the-health-check/

    Moderator Yui

    (@fierevere)

    永子

    @chrisfang

    I’ve removed MySQL connection settings and Salts from your posted wp-config.php file.

    Please do not post sensitive data on public forums, but since you’ve done so, consider this data already compromised and a subject to urgent change.

    Thread Starter chrisfang

    (@chrisfang)

    @mikachan thanks for your help.

    it is the Woocommerce product pages.when i activate it.the products will be displayed.
    when i click the product.problem comes.

    Health Check & Troubleshooting/Woocommerce now are activated.rest are deactivated.
    problem still exists.

    does that means it is the Woocommerce has problem?

    now how to solve it?

    If you’ve disabled all other plugins and activated a default (Twenty*) theme, this does sound like a Woocommerce conflict or issue. I’d recommend asking in their support forums as they’ll have a better idea of what the issue could be. If it turns out to be more to do with your WordPress setup, we’ll still be here to help as well.

    It’s probably helpful to find out what version of PHP you’re running. If you’re not sure, your host will be able to tell you.

    Thread Starter chrisfang

    (@chrisfang)

    @mikachan thank you very much

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Parse error: syntax error, unexpected ‘ ‘ (T_STRING) i’ is closed to new replies.