WordPress.org

Ready to get started?Download WordPress

Forums

Redirection
[resolved] Missing argument 2 for wpdb::prepare() (35 posts)

  1. M
    Member
    Posted 11 months ago #

    Full description of warning is: Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/redirection/models/group.php on line 70 and defined in /public_html/wp-includes/wp-db.php on line 992

    Looks like there's some sort of conflict with the newly launched WP 3.6. Fixing this will be really appreciated, since this plugin has proved to be an indispensible one.

    Thank you!

    http://wordpress.org/plugins/redirection/

  2. MCM
    Member
    Posted 11 months ago #

    I would also be keen to know how to fix this.

  3. FolioVision
    Member
    Posted 11 months ago #

    Hello John,

    we are also getting this error. It appears in Tools -> Redirection only.

    Thanks,
    Martin

  4. Discman3
    Member
    Posted 11 months ago #

    I have the same problem, how to fix it ?

  5. MCM
    Member
    Posted 11 months ago #

    I had this issue in my functions.php

    BEFORE
    $post_count = $wpdb->get_var( $wpdb->prepare($sql));

    AFTER
    $post_count = $wpdb->get_var( $wpdb->prepare($sql, $count));

    I do not understand it exactly, but I looked it up on CODEX and everything still works, I just added the $count at the end.

  6. tfagen
    Member
    Posted 11 months ago #

    Yup- updated to WP 3.6 and Warning: Missing argument 2 for wpdb::prepare(), called in .../plugins/redirection/models/group.php on line 70 and defined in .../wp-includes/wp-db.php on line 992

  7. Hansaplastique
    Member
    Posted 11 months ago #

    It's unfortunately not a WordPress bug ... it's a developers mistake like MCM confirms :)

    See also: Prepare Missing Argument and PHP Warning Missing Argument.

  8. totalgaz
    Member
    Posted 11 months ago #

    I got the same issue appearing on the plugin settings page in WP dashboard. John please add the patch needed cos this plugin rocks. Least it does still work in the meantime.

  9. laserjobs
    Member
    Posted 11 months ago #

    Same problem here. This error should not be hard to fix but I am traveling right now.
    Line 70:
    $rows = $wpdb->get_results( $wpdb->prepare( "SELECT {$wpdb->prefix}redirection_modules.name AS module_name,{$wpdb->prefix}redirection_groups.name AS group_name,{$wpdb->prefix}redirection_groups.id FROM {$wpdb->prefix}redirection_groups INNER JOIN {$wpdb->prefix}redirection_modules ON {$wpdb->prefix}redirection_modules.id={$wpdb->prefix}redirection_groups.module_id ORDER BY {$wpdb->prefix}redirection_modules.name,{$wpdb->prefix}redirection_groups.position" ) );

    Also there seems to be a bad link with the URL at the top of the page "Redirections for group: Redirections"

    /wp-admin/redirection?page=redirection.php&sub=groups&id=1
    /wp-admin/tools.php?page=redirection.php&sub=groups&id=1

    I also noticed there has not been any development since 2012. Does anyone recommend an updated plugin or want to start the development back up for this one?

  10. tfagen
    Member
    Posted 11 months ago #

    Remove the plugin and try fancy gallery lite. It only supports 1 gallery free under 3.6 but it works really well. Worth paying $29 for the full version.

    I'm sure there are others too but this one is simple to use, worked first shot, and has many more options and features than I'll ever use.

  11. laserjobs
    Member
    Posted 11 months ago #

    Here is the fix
    https://gist.github.com/theandystratton/4565222

    On line 70 of redirection/models/group.php
    Remove the "( $wpdb->prepare" and " )" at the end

  12. M
    Member
    Posted 11 months ago #

    @laserjobs: thanks! Your fix works.

  13. Esteban Gallego
    Member
    Posted 11 months ago #

    @laserjobs; Thanks!!! it works.

  14. Chris
    Member
    Posted 11 months ago #

    Thanks @laserjobs that fixed it!

  15. SiteDesignUSA
    Member
    Posted 11 months ago #

    Also had this problem and the gist fix works. Thanks.

  16. baraklevy
    Member
    Posted 11 months ago #

    the redirection plug causes my homepage to disappear!
    only when I deactivate the plug I can see my homepage.

    I cloned the site to develop server, you can see it here:
    earnix.tweendev.com

    you see? - blank homepage. all the other pages are working fine.
    earnix.tweendev.com/earnix-for-insurance/earnix-for-insurance/

    Is there a way to fix it?

  17. baraklevy
    Member
    Posted 11 months ago #

    I see that I have this error on the redirection setting page:
    Warning: Missing argument 2 for wpdb::prepare(), called in /home/tweendev/public_html/earnix/wp-content/plugins/redirection/models/group.php on line 70 and defined in /home/tweendev/public_html/earnix/wp-includes/wp-db.php on line 992

    but there is no update request to this plugin - so I understand that I am using the final version, right? and if I understand right, the final version need to fix this error - right? so why do I see this error?

  18. nathair
    Member
    Posted 11 months ago #

    @laserjobs: thank you for posting the fix.
    Worked for one of my sites as well.

    Here is the temporary fix
    https://gist.github.com/theandystratton/4565222

    On line 70 of redirection/models/group.php
    Remove the "( $wpdb->prepare" and " )" at the end

  19. baraklevy
    Member
    Posted 11 months ago #

    but -
    I cant fined in the plugin folder a PHP file with this name:
    redirection-models-group.php

  20. baraklevy
    Member
    Posted 11 months ago #

    OK,
    I Placed the fix code in the "group.php" file.
    and this internal error gone
    BUT-the homepage is still blank!!!

    can someone here help me?

  21. wrbenton
    Member
    Posted 10 months ago #

    @laserjobs: thanks! Works like a champ.

  22. wrbenton
    Member
    Posted 10 months ago #

    @baraklevy - the file is not redirection-models-group.php That was the path - Look in your wp-content folder, then in the plugins folder, then in the redirection folder, then in the models folder. In here you will find the file group.php

    Navigate to line 70 and make the changes. If you go to the github page (https://gist.github.com/theandystratton/4565222), it shows you the old line 70 and the new line 70 with explanations.

    Hope this helps!

  23. MFJLabs
    Member
    Posted 10 months ago #

    Thx laserjobs - fix seems to clean up the error just fine.

    I think johnny5 (aka John Godley) has a new baby girl and may be a little busy, but don't know for sure. Found pics on johngodley.com blog.

    If that's you man, thank you for the plugin. I know if I ever had to choose between spending time with my beautiful baby daughter and us pranksters ... well ... I'd sit her on my lap while I worked, but that's just me. ;-)

    Congratulations and take care.
    Best,
    Frank

  24. WIMASURINAME
    Member
    Posted 10 months ago #

    The plugin gives the following error :
    Warning: Missing argument 2 for wpdb::prepare(), called in /home/wima/domains/info-suriname.com/public_html/suriname/wp-content/plugins/redirection/models/group.php on line 70 and defined in /home/wima/domains/info-suriname.com/public_html/suriname/wp-includes/wp-db.php on line 992

    i used the hot fix:
    $rows = $wpdb->get_results( “SELECT {$wpdb->prefix}redirection_modules.name AS module_name,{$wpdb->prefix}redirection_groups.name AS group_name,{$wpdb->prefix}redirection_groups.id FROM {$wpdb->prefix}redirection_groups INNER JOIN {$wpdb->prefix}redirection_modules ON {$wpdb->prefix}redirection_modules.id={$wpdb->prefix}redirection_groups.module_id ORDER BY {$wpdb->prefix}redirection_modules.name,{$wpdb->prefix}redirection_groups.position” );

    Bud then it gives a error again:
    Parse error: syntax error, unexpected ‘;’ in /home/wima/domains/info-suriname.com/public_html/suriname/wp-content/plugins/redirection/models/group.php on line 70

    This error is caused because the ) at the end cannot be removed can you please tel me how to fix this.

  25. cobrabb
    Member
    Posted 10 months ago #

    wp-includes/wp-db.php in line 992:

    Replace this:

    function prepare( $query, $args ) {
    if ( is_null( $query ) )
    return;

    With:

    function prepare( $query, $args = null ) {
    if ( is_null( $query ) )
    return;

    It will fix wordpress 3.6 :)

  26. neeraj10786
    Member
    Posted 8 months ago #

    @cobrabb
    Perfect
    you solved my issue

    today i just updated my wordpress theme with latest one 3.7
    and i got this error
    after long surfing i got the solution at here
    thanks for the solution

  27. Ruffo
    Member
    Posted 8 months ago #

    Excellent!!

    You solved my issue cobrabb. Eternally Grateful

    Thank you very much!!

  28. jyegestiones
    Member
    Posted 8 months ago #

    Hi, I have a similar error.
    Warning: Missing argument 2 for wpdb::prepare(), called in /home/user_cpanel/public_html/wp-content/plugins/limit-bogs-per-user.php on line 112 and defined in /home/user_cpanel/public_html/wp-includes/wp-db.php on line 992

    these are the codes:
    /public_html/wp-content/plugins/limit-bogs-per-user.php on line 112 = $role=$wpdb->get_results($wpdb->prepare($role_sql),ARRAY_A);

    public_html/wp-includes/wp-db.php on line 992 =
    function prepare( $query, $args ) {

    Any suggestions?
    thank you very much

  29. cobrabb
    Member
    Posted 8 months ago #

    WordPress theme and Wp version?

  30. jyegestiones
    Member
    Posted 8 months ago #

    Hello, wordpress version I have is 3.7.1, is a version in Spanish

Reply »

You must log in to post.

About this Plugin

About this Topic