Title: prepare() function issues
Last modified: August 22, 2016

---

# prepare() function issues

 *  Resolved [orangeworx](https://wordpress.org/support/users/orangeworx/)
 * (@orangeworx)
 * [11 years ago](https://wordpress.org/support/topic/prepare-function-issues/)
 * I’ve had this site and the theme is no longer supported, developer decided to
   stop further work and i’ve been trying to figure out the fix to this and basically
   forgot about it for like a couple years – judging by the post dates regarding
   this matter, specifically this [one](http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/).
   
   so my error is this: Warning: Missing argument 2 for wpdb::prepare(), called 
   in wp-content/themes/MnC/lib/engine/nws-admin-functions.php on line 2680 and 
   defined in /wp-includes/wp-db.php on line 1152
 * and this is the chunk of code:
 * function nws_get_theme_version() {
    global $wpdb;
 *  $th_vers = NULL;
 *  // the table
    $table = is_dbtable_there(‘status’); // the sql $th_vers = $wpdb-
   >get_var( $wpdb->prepare( “SELECT th_vers FROM $table WHERE id = 1 LIMIT 0,1”));
 *  return $th_vers;
    }
 * [this](https://wordpress.org/support/topic/missing-argument-2-for-wpdbprepare-14?replies=3)
   other link on the other hand, is pretty much the same exact situation and i’d
   bet money the user was using the same theme… but the fix crashes the whole site(
   google only gave me another [link](https://www.google.ca/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0CCUQFjAB&url=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ferror-with-wp-35-wpdbprepare&ei=G0wTVejbOcWjNrarg6gO&usg=AFQjCNEYD8ICF7DHf74axkivZI8jXqrkng&sig2=4tbJqKgby8zvYAuQBHFQtA)
   with a couple of people having the same line of code/error combination but no
   response/fix)
 * I’d like to know how that can be fixed, not necessarily looking into changing
   the whole website, as most posts state, if you’re a user you won’t be affected,
   and I’m not really keen on turning off warnings.
 * Thanks for your input and time
    Fredo

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [orangeworx](https://wordpress.org/support/users/orangeworx/)
 * (@orangeworx)
 * [11 years ago](https://wordpress.org/support/topic/prepare-function-issues/#post-5942616)
 * anyone?
 *  [Ramesh (thecodeisclear)](https://wordpress.org/support/users/thecodeisclear/)
 * (@thecodeisclear)
 * [11 years ago](https://wordpress.org/support/topic/prepare-function-issues/#post-5942617)
 * Hi,
 * From the first link you gave, I think you don’t need a prepare call at all (since
   no arguments are being passed)
 * You could replace the line after `//the sql` like this
 * `$th_vers = $wpdb->get_var( "SELECT th_vers FROM $table WHERE id = 1 LIMIT 0,1");`
 * this should get rid of the warning.
 *  Thread Starter [orangeworx](https://wordpress.org/support/users/orangeworx/)
 * (@orangeworx)
 * [11 years ago](https://wordpress.org/support/topic/prepare-function-issues/#post-5942619)
 * Sweet! [@thecodeisclear](https://wordpress.org/support/users/thecodeisclear/)
   Thank you so much 😀 this has resolved my issue… i was seeing this error on almost
   every page in my admin and even several times per options page/tab
 * Thanks again! I really appreciate your help!
 *  [Ramesh (thecodeisclear)](https://wordpress.org/support/users/thecodeisclear/)
 * (@thecodeisclear)
 * [11 years ago](https://wordpress.org/support/topic/prepare-function-issues/#post-5942621)
 * Welcome [@orangeworx](https://wordpress.org/support/users/orangeworx/), but you
   had already done all the research. 🙂

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘prepare() function issues’ is closed to new replies.

 * 4 replies
 * 2 participants
 * Last reply from: [Ramesh (thecodeisclear)](https://wordpress.org/support/users/thecodeisclear/)
 * Last activity: [11 years ago](https://wordpress.org/support/topic/prepare-function-issues/#post-5942621)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
