missing argument

Discussion in 'PHP' started by irdogg, Dec 27, 2013.

  1. #1
    Warning: Missing argument 2 for wpdb::prepare(), called in /home4/555/public_html/mysite.com/store/wp-content/plugins/amz-aff-store/smart_framework/functions/core.php
    on line 17 and defined in /home4/555/public_html/mysite.com/store/wp-includes/wp-db.php on line 992
    
    
    line 17    return $wpdb->get_var($wpdb->prepare("SELECT COUNT(option_name) FROM $wpdb->options WHERE option_name = '$option';"));
    
    
    line 992  function prepare( $query, $args ) {
    
    
    Code (markup):

     
    Solved! View solution.
    irdogg, Dec 27, 2013 IP
  2. #2
    Dunno the code (or, rather, the wrappers you're using, but you do have a superfluous ; at the end there - change this:
    
    option_name = '$option';"));
    
    PHP:
    to
    
    option_name = '$option'"));
    
    PHP:
    Second, you're using wpdb completely wrong - which a quick Google-search would have told you.
    Have a look here:
    http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/

    And change the code further, to something like this:
    
    option_name = %s", $option));
    
    PHP:
    And, I suggest reading up on the usage, or if this is a plugin, make sure you run the latest version.
     
    PoPSiCLe, Dec 27, 2013 IP
  3. irdogg

    irdogg Well-Known Member

    Messages:
    358
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    135
    #3
    
    Parse error: syntax error, unexpected '=' in /home4/555/public_html/mysite.com/store/wp-includes/wp-db.php on line 1747
    Code (markup):
    added
    wp-db file

        /**
         * Retrieve the name of the function that called wpdb.
         *
         * Searches up the list of functions until it reaches
         * the one that would most logically had called this method.
         *
         * @since 2.5.0
         *
         * @return string The name of the calling function
         */
        function get_caller() {
            return wp_debug_backtrace_summary( __CLASS__ );
        }
    
        /**
         * The database version number.
         *
         * @since 2.7.0
         *
         * @return false|string false on failure, version number on success
         */
        function db_version() {
            return preg_replace( '/[^0-9.].*/', '', mysql_get_server_info( $this->dbh ) );
        }
    }
    option_name = %s", $option));
    Code (markup):
     
    irdogg, Dec 27, 2013 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    Uh, the code above won't do anything, except throw an erro - you still need all the rest of the code you pasted in the first post, just change the end of the line to what I showed.
     
    PoPSiCLe, Dec 27, 2013 IP
  5. irdogg

    irdogg Well-Known Member

    Messages:
    358
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    135
    #5
    the code is from 2 files the lines that are causing the error in the first post
     
    irdogg, Dec 27, 2013 IP
  6. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #6
    My point was - the file you posted, wp-db - if the last line in that file is option_name = %s", $options)); then you've done a booboo. And you really need to read up on PHP.
     
    PoPSiCLe, Dec 27, 2013 IP
  7. irdogg

    irdogg Well-Known Member

    Messages:
    358
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    135
    #7
    ok that did the trick thanx man!!
     
    irdogg, Dec 27, 2013 IP