I am creating simple searching script with LIKE clause.
Below is the simple query with LIKE clause using php.
$rows = mysql_query("select * from description where tags like '%{$keyword}%'");
This above query work successfully. But LIKE clause not working with $wpdb->prepare()
. Below is the code for that
$rows = $wpdb->get_results($wpdb->prepare("select * from description where tags like '%{%s}%'",$keyword));
What I am missing in this?
You need to escape the % character,
try this:
I usually use sprintf, and do something similar to this.