Take the tour ×

I'm writing a feed reader plugin for wordpress. I'm seeing a DB error that I can't figure out. First I create a table called user_entries. Then I put a sample entry into that table. When I try to delete an entry, I get a very strange error in my debug log. There are no foreign keys yet, no indices on the db, etc.

[02-May-2012 11:21:52] WordPress database error for query DELETE FROM wp_wprss_user_entries
WHERE owner_uid = 2 AND feed_id = 2; made by do_action, call_user_func_array, wprss_unsubscribe_feed, WprssFeeds->remove

So what is the error? It's just blank in there. This doesn't look like complicated SQL and it works fine in the phpmyadmin query window. I'm not sure what to do for a next step now, and I'd like folks to be able to unsubscribe from a feed!

share|improve this question
Echo that query and run it directly on your db table via PHPMyAdmin... –  Rutwick Gangurde May 2 '12 at 11:52
Actually did that - the query wasn't actually throwing an error or having a problem. See stephan's answer... –  MattK May 3 '12 at 2:20
Cool... glad you found a solution... –  Rutwick Gangurde May 3 '12 at 5:13
add comment

closed as too localized by Stephen Harris, Rarst Oct 4 '12 at 17:25


1 Answer

up vote 3 down vote accepted

The code you've linked to above:

    //$sql set to raw SQL statement
    $sql = $wpdb->prepare($sql,$feed_id);

      $resp->uf_error = $wpdb->print_error();

So if there isn't, an error you try displaying the 'error' with $wpdb->print_error(). Also$wpdb->print_error() doesn't return an error, it prints it.

It's (probably) the printing of that non-error that is causing an error in your second database query, the one for which an error is logged.

Side note: take a look at the wpdb class. There are methods in there that handle INSERT/UPDATE queries so you don't have to do them manually.

share|improve this answer
Thanks Stephan! –  MattK May 3 '12 at 2:12
add comment
