0

I am working on a website that uses a previously developed image slider plugin. I had it all working in my local environment but once I took it live it kicked the following error anywhere the image slider is located...

Warning: Missing argument 2 for wpdb::prepare(), called in
/home/content/r/o/b/robertrhuspeak/html/desarch/wp
content/plugins/portfolio/fields.php on line 48 and defined in
/home/content/r/o/b/robertrhuspeak/html/desarch/wp-includes/wp-db.php on line 1246

The line of code it is referencing looks like this...

$fields = $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value,
meta_order IS NULL AS isnull FROM $wpdb->postmeta WHERE post_id=$postID ORDER BY
isnull ASC, ABS(meta_order) ASC, meta_id"));

My understanding is that wp-db.php is expecting two arguments and the above code is not written with two arguments.

BUT, I frankly have no idea how it should be written. And I have dug hard on the Internet to find something that will explain it to me clearly.

Any guidance would be greatly appreciated.

Thanks!

0

2 Answers 2

0

Nacin summed it up in detail and I'm guessing this is a duplicate (looking in a minute), for now go read this

0

This is how it should be written:

$fields = $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value,
meta_order IS NULL AS isnull FROM $wpdb->postmeta WHERE post_id=%d ORDER 
BY isnull ASC, ABS(meta_order) ASC, meta_id", $postID));

See this explanation

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