A
A
ANVARD2014-08-21 04:55:20
PHP
ANVARD, 2014-08-21 04:55:20

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

1 answer(s)
A
Alexander Zelenin, 2014-08-21
@zelenin

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 question

Ask a Question

731 491 924 answers to any question