WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [closed] Front-end warning: Missing Argument for wpdb (23 posts)

  1. noelani
    Member
    Posted 1 year ago #

    I'm getting this error message. I've looked up solutions but all the ones I've found relate to specific plugins or don't exactly address the issue I have, because it's something conflicting with the premium theme I'm using and the creator as packed up and shipped off. He dosn't offer support for this anymore.

    Below is the error message I'm getting. Can anyone help?

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/XXX/public_html/XXXXXX.com/wp-content/themes/MinFolio/functions/custom-functions.php on line 77 and defined in /home/XXXX/public_html/XXXXXX.com/wp-includes/wp-db.php on line 990

  2. Hi noelani,

    You should disable error reporting/display and contact the author of your theme about the error.

    You can refer them to this link: https://core.trac.wordpress.org/changeset/22429

  3. noelani
    Member
    Posted 1 year ago #

    I tried because his widgets kept breaking, but he never responded. Now he has disappeared and has no forwarding information to contact. Can I solve the issue myself with the information in the link?

  4. Is it the one from http://www.w-portfolio.com/ ?

  5. noelani
    Member
    Posted 1 year ago #

    No, it's not from there. I actually just got a response from the site where I purchased it from. The seller has disappeared, removed his website and deleted all his social network pages. They are going to rectify the situation for me. So maybe I can just scrap this one and get a new theme. It's not worth the headache anymore.

  6. WaitWhereAmI
    Member
    Posted 1 year ago #

    I'm in the same exact situation with a missing author, though judging by the the error you posted we are using a different theme. I'm in too deep to use a different theme, what are my options in terms of having someone look at my code or troubleshooting this on my own?

  7. noelani
    Member
    Posted 1 year ago #

    If you have a good web hosting company one of their technical support technicians might help you out. My sites are hosted through name.com and although they do not and are not required to offer third party support, they've helped me with issues from time to time.

  8. WaitWhereAmI
    If you create a new topic, somebody can probably help you out.

  9. rmgalica
    Member
    Posted 1 year ago #

    I'm getting

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/content/h/e/a/healingheart1/html/HHC/wp-content/plugins/wp-super-edit/wp-super-edit.core.class.php on line 114 and defined in /home/content/h/e/a/healingheart1/html/HHC/wp-includes/wp-db.php on line 990

    This appeared after upgrading the 2 wordpress themes 2010 & 2011 or from upgrading to WordPress 3.5. How can I fix this?

    We use all of the settings, themes, etc directly from the generic install of wordpress.

  10. Marviene
    Member
    Posted 1 year ago #

    I'm getting these errors also. I use a Nimble theme. Errors on lines 8, 81 & 102

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/marviene/public_html/wp-content/themes/dt-nimble/functions/core/core-filters.php on line 8 and defined in /home/marviene/public_html/wp-includes/wp-db.php on line 990

    and

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/marviene/public_html/wp-content/themes/dt-nimble/functions/core/core-functions.php on line 81 and defined in /home/marviene/public_html/wp-includes/wp-db.php on line 990

    and

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/marviene/public_html/wp-content/themes/dt-nimble/functions/core/core-functions.php on line 102 and defined in /home/marviene/public_html/wp-includes/wp-db.php on line 990

    HELP!!

  11. Samuel Wood (Otto)
    Tech Ninja
    Posted 1 year ago #

    This warning occurs when somebody is using the $wpdb->prepare function incorrectly. It's a bad warning to have too, because it indicates a usage of prepare() in a way that can be a security risk.

    Fixing it depends on the specific problem.

    Here's an example line of code that I took from a plugin that was doing-it-wrong:

    $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->comments SET comment_parent=$parentID WHERE comment_ID=$commentID;" ) );

    The basic problem is that they're using the prepare statement incorrectly by including the variables of $parentID and $commentID directly in the SQL statement. They should be using placeholders, and then including the variables later.

    This code is dangerous, because it leads to the possibility of what is called an "SQL Injection Exploit". Which is shorthand for a specific way to hack your site.

    Here's the fixed code:

    $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->comments SET comment_parent=%d WHERE comment_ID=%d;", $parentID, $commentID ) );

    Basically, since both of these are supposed to be integers, I replaced the variables in the statement with %d and then put the variables are the end of the prepare() statement. This is how prepare is supposed to be used. If they were strings, I would have used %s instead.

    So if you want to fix the issue, you need to find the line of code with the problem, and correct it. This eliminates the exploit. And the warning message.

  12. Samuel Wood (Otto)
    Tech Ninja
    Posted 1 year ago #

    If the message is coming from a plugin, then the best course of action is to:
    a) deactivate the plugin and
    b) notify the author.

    With a theme, notifying the author is good, but if you can't get them to fix it, then you'll need to fix it yourself.

  13. rmgalica
    Member
    Posted 1 year ago #

    What do you mean the author? them? It - is - from - WordPress!!

    Why did they tell us to upgrade if their update is broken? I have no idea what you are even talking about. This is supposed to be the user-friendly web publishing software. All I do is point and click like the directions tell me to.

    I do know where to deactivate plug-ins so I guess that's my only choice, and hope the website doesn't implode *lol*.

    Thanks for your answer!!

  14. noelani
    Member
    Posted 1 year ago #

    Hi Samuel,
    Since it states two lines of code in the error message, I'm assuming that's where the problem is, but again, I'm not a coder, so knowing where the problem is doesn't help, because I'm lost after that. I spent a couple hours going over it and looking on google for a solution, but I was scared to change anything that didn't specifically relate to where the problem is. For instance, mine is with a line of code in the theme, so I didn't want to use a plugin fix for something that effects the theme. Does that make sense?

    Here are the lines of code mentioned in the error message:

    in wp-db.php:

    function prepare( $query, $args ) {

    and in the theme in functions/custom-functions.php

    $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $prefix . "posts" . " WHERE guid='" . $image_url . "';"));

    If you could help I would greatly appreciate it.

  15. Samuel Wood (Otto)
    Tech Ninja
    Posted 1 year ago #

    @rmgalica: The error message you posted indicates that the error is coming from a plugin called "wp-super-edit". The key is to read the error message, specifically, this part:

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/content/h/e/a/healingheart1/html/HHC/wp-content/plugins/wp-super-edit/wp-super-edit.core.class.php on line 114

    The author of that plugin is not "WordPress", it is the guy listed as the author on the plugin page:
    http://wordpress.org/extend/plugins/wp-super-edit/

    @noelani: Your error message is coming from the theme. The second line of code states where the function is defined, where it's called from is the problem.

    In your case, that line of code you posted is definitely the problem. Here's the fixed version of that line:

    $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $prefix . "posts WHERE guid=%s;", $image_url));
  16. noelani
    Member
    Posted 1 year ago #

    Thanks so much, Samuel, well that definitely fixed that particular issue. I turned back on the error reporting and no more warning!

  17. Marviene
    Member
    Posted 1 year ago #

    Mr. Wood, you said "This code is dangerous, because it leads to the possibility of what is called an "SQL Injection Exploit". Which is shorthand for a specific way to hack your site."

    Do you think that the 3 theme wpdb errors I posted above - that first appeared after this WP update - are the reasons that my Amazon banners & Widgets were being hijacked by stampedemedia?

    &.... would you PLEASE look at the 3 errors I posted above and tell me the right code? Pretty please?

  18. Samuel Wood (Otto)
    Tech Ninja
    Posted 1 year ago #

    @Marviene: Call me "Otto". :)

    Without the actual lines of code that those errors refer to, there's really no way for me to tell. However, I think it's doubtful that that is how you were having the problems you describe. The attack I'm talking about isn't exactly theoretical, but it's a tricky one to perform on any given site without deeper knowledge of the site itself.

  19. Marviene
    Member
    Posted 1 year ago #

    Thank you Otto,

    It's actually quite a relief that these holes aren't easy to hack. We've asked the theme maker to take a look at it.

    : ) Have a good day and once again, thank you!

  20. gruberj
    Member
    Posted 1 year ago #

    Hello Otto,

    After upgrading to 3.5, I am getting the following one line error message:

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/asiaconf/public_html/wp-content/plugins/wp-super-edit/wp-super-edit.core.class.php on line 114 and defined in /home/asiaconf/public_html/wp-includes/wp-db.php on line 990

    The relevant code is:

    function prepare( $query, $args ) {

    How do I fix this to remove the error?

    Thanks

  21. marujobhz
    Member
    Posted 1 year ago #

    i have a fake solution:
    reup this file wp-db, in wp version 3.4.2, overwrite the same file of wp 3.5. the error stops for me, until the owner of site send me a real solution.

  22. maxineann
    Member
    Posted 1 year ago #

    Hi! I am using The Jewelry Shop theme from Sarah Neuber.

    I also have the same problem:
    Warning: Missing argument 2 for wpdb::prepare(), called in /home3/momentib/public_html/lavitabellashop/wp-content/themes/TheJewelryShop/lib/engine/cart_actions.php on line 6626 and defined in /home3/momentib/public_html/lavitabellashop/wp-includes/wp-db.php on line 990

    How do I go about solving this?

    I cannot contact my theme author since she has removed the email for contact and they also removed themselves from theme forest.

    I really need to know how to fix this.

    Thanks!

  23. QuentinWeber
    Member
    Posted 1 year ago #

    have a similar issue

    $wpdb->prepare( "
    SELECT * FROM {$wpdb->prefix}woocommerce_shipping_zones
    ORDER BY zone_order ASC
    " ) );

    not sure what i need to be adding to the above code to make it work

Topic Closed

This topic has been closed to new replies.

About this Topic