我需要帮朋友,但我从未使用过wordpress。这是代码段不起作用。我明白了:
mysql_fetch_object():提供的参数不是有效的MySQL结果资源
以下是代码:
$dldb2 = mysql_connect("localhost","x","yz");
if(current_user_can('manage_options')) {
$sql2 = "SELECT " . $wpdb->prefix . "resellerlicensing_customer.*,prod_name, date AS dateandstatus FROM monopoly_wp1." . $wpdb->prefix . "resellerlicensing_customer LEFT JOIN monopoly_customersdlg.products ON " . $wpdb->prefix . "resellerlicensing_customer.prod_num=products.prod_num INNER JOIN monopoly_customersdlg.customers ON monopoly_customersdlg.customers.receipt=monopoly_wp1." . $wpdb->prefix . "resellerlicensing_customer.licensekey";
} else {
$sql2 = "SELECT " . $wpdb->prefix . "resellerlicensing_customer.*,prod_name, date AS dateandstatus FROM monopoly_wp1." . $wpdb->prefix . "resellerlicensing_customer LEFT JOIN monopoly_customersdlg.products ON " . $wpdb->prefix . "resellerlicensing_customer.prod_num=products.prod_num INNER JOIN monopoly_customersdlg.customers ON monopoly_customersdlg.customers.receipt=monopoly_wp1." . $wpdb->prefix . "resellerlicensing_customer.licensekey WHERE userid=" . $userid . "";
}
$result2 = mysql_query($sql2,$dldb2);
$customers = array();
while($row = mysql_fetch_object($result2)){ ... }