Converting mysql_query to $wpdb->get_results

柔情痞子 提交于 2019-12-02 08:36:22

mysql_query return a resource. So you get this error by using $wpdb->get_results.

mysql_query() returns TRUE on success or FALSE on error. The returned result resource should be passed to mysql_fetch_array(), and other functions for dealing with result tables, to access the returned data.

You will replace 2 function mysql_fetch_array() and mysql_query instance of $wpdb->get_results. You will define return type -- ARRAY_A, ARRAY_N , OBJECT ,OBJECT_K

global $wpdb;

$ck_sql = $wpdb->get_results("SELECT ck_ips, ck_rating_up, ck_rating_down FROM `$table_name` WHERE ck_comment_id = $comment_id", ARRAY_A);
foreach($ck_sql as $row) {
    echo $row['ck_ips'] . ' ' . $row['ck_rating_up']. ' ' . $row['ck_rating_down '];
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!