0

I am trying to get Mysql values from outside wp. My code:

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");

What i missed ?

1 Answer 1

1

option_name is type VARCHAR, iow. a string

Try:

$wpdb->get_var("SELECT option_value FROM wp_options WHERE option_name = 'siteurl'");
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.