• Resolved Aranworld

    (@aranworld)


    I am using get_col to get a listing of years in which posts were created for a given post category. The query works great on my local server AND the raw query works in both my local MySQL db and the remotely hosted MySQL db.

    However the code, when run on the remote web-server version of WordPress returns an empty result when run within a page.

    Again, the following code works on my home server, but returns an empty result on my live server:

    $years=$wpdb->get_col(
    			    "SELECT DISTINCT YEAR(post_date)
    	            FROM $wpdb->posts key1, $wpdb->term_relationships term
    	            WHERE key1.ID = term.object_id
    	            AND term.term_taxonomy_id = 55
    	            ORDER BY post_date" );

    Does anyone know wny a query would work in phpMyAdmin, but not work when run within WordPress itself?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Different MySQL version maybe? Is there any errors in the PHP log?

    The following snippet will echo the errors is there is any.

    global $wpdb;
    $wpdb-> show_errors();

    Thread Starter Aranworld

    (@aranworld)

    No errors are being displayed when I do show_errors();

    Even when I do a very simple query like this:

    $first_post=$wpdb->query( "SELECT * FROM wp_posts LIMIT 1" );

    I get an empty result. Is it possible that the query functions have been disabled on my remote server?

    Thread Starter Aranworld

    (@aranworld)

    You know it seems like something has been disabled in my WordPress installation, because when I do this:

    global $wpdb;
     $result=$wpdb->query( "SELECT * FROM wp_posts LIMIT 1"
    			     );
     echo $wpdb->func_call;

    On my local server I see this expecte result:

    $db->query("SELECT * FROM wp_posts LIMIT 1")

    On my remote server absolutely nothing gets echoed to the screen.

    Thread Starter Aranworld

    (@aranworld)

    I think this might be related to my current host. I am using GoDaddy.

    It appears that I am unable to access the $wpdb object. No attempt at connecting to it are working.

    Thread Starter Aranworld

    (@aranworld)

    I finally figured it out. APC caching was turned on, which is normally good, but it meant that the modifications I was making to the page template were just not appearing on the website. After temporarily disabling apc caching, everything was back to normal again.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘get_col returning empty result on remote server’ is closed to new replies.