我正在尝试从wp外部获取Mysql值。我的代码:
define( \'BLOCK_LOAD\', true );
require_once( $_SERVER[\'DOCUMENT_ROOT\'] . \'/wp-config.php\' );
require_once( $_SERVER[\'DOCUMENT_ROOT\'] . \'/wp-includes/wp-db.php\' );
$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
$wpdb->get_var("SELECT option_value FROM wp_options WHERE option_name = siteurl");
我错过了什么?
最合适的回答,由SO网友:shanebp 整理而成
option\\u name的类型为VARCHAR,iow。字符串
尝试:
$wpdb->get_var("SELECT option_value FROM wp_options WHERE option_name = \'siteurl\'");