//include_once "WP-ROOT-PATH/wp-config.php";
//include_once "../../../wp-includes/wp-db.php";
//define( \'BLOCK_LOAD\', true );
//require_once( $_SERVER[\'DOCUMENT_ROOT\'] . \'/wordpress/wp-config.php\' );
//require_once( $_SERVER[\'DOCUMENT_ROOT\'] . \'/wordpress/wp-includes/wp-db.php\' );
//$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
//i tried all these method to access wp files but gives error//////
class repository{
function save($name,$email,$address1,$address2,$code)
{
global $wpdb;////this variable is null now
$wp_Table_name = $wpdb->prefix.\'conssv12frm\';
$status = $wpdb->insert(
$wp_Table_name,
array(
"name" => $name,
"email" => $email,
"address1"=> $address1,
"address2"=> $address2,
"code"=> $code
),
array(
\'%s\',
\'%s\',
\'%s\',
\'%s\',
\'%d\'
)
);
$message = $status?"Data has been inserted":"Server Error";
return new response($status,null,null,$message);
}
}
在这里
$wpdp
返回null。我到处都找遍了
wp-config.php
和
wp-include/wp-admin.php
, 访问
$wpdb
变量,但它给出了文件未找到的错误。