确保数据库连接正确
define(\'DB_NAME\', \'database-name\');
define(\'DB_USER\', \'database-username\');
define(\'DB_PASSWORD\', \'database-password\');
define(\'DB_HOST\', \'localhost\');
您应该使用普通php文件进行测试,以连接数据库,如下代码所示
<?php
$connect = mysql_connect(\'localhost\', \'root\', \'password\');
if (!$connect) {
die(\'Could not connect: \' . mysql_error());
}
echo \'Connected successfully\';
mysql_close($connect);
要使其在本地主机或生产环境中具有灵活性,请使用这种方式,
<?php
switch ( $_SERVER[\'HTTP_HOST\'] ) {
case \'yourdomain.dex\': //local
define( \'DB_NAME\', \'rino\' );
define( \'DB_USER\', \'root\' );
define( \'DB_PASSWORD\', \'\' );
define( \'DB_HOST\', \'localhost\' );
define( \'WP_DEBUG\', true );
define( \'WP_DEBUG_DISPLAY\', true );
define( \'SCRIPT_DEBUG\', true );
define( \'WP_DEBUG_LOG\', true );
define( \'FS_METHOD\', \'direct\');
@ini_set( \'display_errors\', true );
define( \'ENV\', \'dev\' );
break;
case \'yourdomain.staging.com\': //staging
define( \'DB_NAME\', \'creati_444\' );
define( \'DB_USER\', \'creatisd\' );
define( \'DB_PASSWORD\', \'lPC44@8u1B\' );
define( \'DB_HOST\', \'localhost\' );
define( \'WP_DEBUG\', true );
define( \'WP_DEBUG_DISPLAY\', true );
define( \'SCRIPT_DEBUG\', true );
define( \'WP_DEBUG_LOG\', true );
@ini_set( \'display_errors\', true );
define( \'ENV\', \'staging\' );
break;
default : //production
define( \'DB_NAME\', \'keikfi\' );
define( \'DB_USER\', \'siekfi\' );
define( \'DB_PASSWORD\', \'lPC@8#u1B\' );
define( \'DB_HOST\', \'localhost\' );
define( \'WP_DEBUG\', false );
define( \'ENV\', \'pro\' );
break;
}
$protocol = ( ! empty( $_SERVER[\'HTTPS\'] ) ) ? \'https://\' : \'http://\';
define( \'WP_SITEURL\', $protocol . $_SERVER[\'HTTP_HOST\'] );
define( \'WP_HOME\', $protocol . $_SERVER[\'HTTP_HOST\'] );
有了以上代码,您不需要关心本地或生产,因为我们可以动态更改网站域,所以它可以工作。正当
而且,您应该使用表修复进行测试
define(\'WP_ALLOW_REPAIR\', true);
上述解决方案不起作用,是时候与主机提供商沟通了:)