Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

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

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the 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

1 Answer 1

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);

    if($wpdb->query($sql)){
      $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

Not the answer you're looking for? Browse other questions tagged or ask your own question.