Answer the question
In order to leave comments, you need to log in
Wordpress: how to get rid of PHP Notice?
Hello,
In Wordpress I make a request:
global $wpdb, $post;
$zapros = $wpdb->get_row($wpdb->prepare("SELECT ID, post_title FROM $wpdb->posts WHERE post_type='post' AND post_status='publish' AND post_author='".$post->post_author. "' AND post_date < '".$post->post_date."' ORDER BY post_date DESC LIMIT 1;", null));
I get a PHP Notice - "The wpdb::prepare function was not called correctly. The wpdb::prepare() method request argument must contain a transform handle."
Please help get rid of this warning.
Thank you in advance!
Answer the question
In order to leave comments, you need to log in
do not use prepare without using binding.
$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts WHERE post_type='post' AND post_status='publish' AND post_author='".$post->post_author."' AND post_date < '".$post->post_date."' ORDER BY post_date DESC LIMIT 1;");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question