• Resolved tribalcomm

    (@tribalcomm)


    I am creating a simple widget that will display the contents of a table that is created by my plugin in the WP database under a new table. The problem I am having is I get:

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

    Can anyone give me an idea of what I am doing wrong? Code is posted below…

    I do not want to add a field to the db for update time…I just want to use this, but I can’t seem to extract it correctly…

    Thanks!

    global $wpdb;
    define('FOO_TABLE', $table_prefix."foo");
    
       /* Get table update time */
       $result = $wpdb->get_results("SHOW TABLE STATUS LIKE '".FOO_TABLE."';");
       while ($array = mysql_fetch_array($result)) {
          $updatetime = $result['Update_time'];
       }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Don’t believe you need the fetch using wpdb class:

    $result = $wpdb->get_results("SHOW TABLE STATUS LIKE '".FOO_TABLE."';");
    foreach ($result as $data) {
    echo $data->Update_time;
    }

    Thread Starter tribalcomm

    (@tribalcomm)

    Holy cow! It worked!!!

    All this time I was trying to figure out the parsing, when I have done foreach so many times…

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘SQL query inside widget – TABLE STATUS’ is closed to new replies.