PHP Parse error: syntax error, unexpected '!&#

2020-05-03 12:10发布

问题:

I am currently using rackspace cloudsites and my wordpress config is not connecting.

Here is the error:

PHP Parse error: syntax error, unexpected '!' in /mnt/stor7-wc1-dfw1/672237/www.site.com/web/content/wp-config.php on line 28

Line 28 seems to be the password field:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', ' 672207_wordpress');

/** MySQL database username */
define('DB_USER', '672207_wpusers');

/** MySQL database password */
define('DB_PASSWORD', ‘!Password’);

/** MySQL hostname */

回答1:

The parse error comes from using curly/smart quotes in ‘!Password’

Change it to '!Password'

They're beautiful, yet deadly.

This may have been caused by using a Word Processor such as Word or similar, or copied from a Website, or the type of quotes on your keyboard.

An IDE would have picked this up.


As stated by Kevin B in a comment, notice how the word "Password" shows up in light blue?

StackOverflow's syntax highlighting has done its job and was a sign.



回答2:

use define('DB_PASSWORD', '!Password'); instead of define('DB_PASSWORD', ‘!Password’);

The correct code:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', ' 672207_wordpress');

/** MySQL database username */
define('DB_USER', '672207_wpusers');

/** MySQL database password */
define('DB_PASSWORD', '!Password');

/** MySQL hostname */