标签:function info sele mysq result 处理 document des 插件
在插件中的一个文件使用如下代码,无法查询
<body> <?php global $wpdb; $sql = ""; $sql = "SELECT * FROM emgAdmin"; $sql = "$sql INNER JOIN wp_posts ON wp_posts.ID = emgAdmin.ID_OfPost "; $ArrResult = $wpdb->get_results($sql); while ($emgAdminResult = mysql_fetch_object($ArrResult)) { echo($emgAdminResult->post_date); } ?> </body>
错误如下:
处理如下:
require_once( $_SERVER[‘DOCUMENT_ROOT‘] . ‘/wp-config.php‘ ); require_once( $_SERVER[‘DOCUMENT_ROOT‘] . ‘/wp-includes/wp-db.php‘ );
完整代码如下:
<?php require_once( $_SERVER[‘DOCUMENT_ROOT‘] . ‘/wp-config.php‘ ); require_once( $_SERVER[‘DOCUMENT_ROOT‘] . ‘/wp-includes/wp-db.php‘ ); $sql = ""; $sql = "SELECT * FROM emgAdmin"; $sql = "$sql INNER JOIN wp_posts ON wp_posts.ID = emgAdmin.ID_OfPost "; $ArrResult = $wpdb->get_results($sql); while ($emgAdminResult = mysql_fetch_object($ArrResult)) { echo($emgAdminResult->post_date); } ?>
Wordpress 数据库查询错误 Call to a member function get_results() on null
标签:function info sele mysq result 处理 document des 插件
原文地址:https://www.cnblogs.com/ryanzheng/p/10362830.html