$db_item = $wpdb->get_results($wpdb->prepare( "SELECT * FROM wp_wowhead_items WHERE name LIKE %s", "%". "Hello" . "%") );
This above one works... But the below one doesn't work!
$text = "Hello";
$db_item = $wpdb->get_results($wpdb->prepare( "SELECT * FROM wp_wowhead_items WHERE name LIKE %s", "%". $text . "%") );
Where am I missing the syntax? I tried almost every combination with quotes, slashes, escapes...
Escape it with double %%
When using get_results() in Wordpress, all % characters inside SQL string literals, including LIKE wildcards, must be double-% escaped as %%
$db_item = $wpdb->get_results($wpdb->prepare(
));
Try this:
Wrap it in quotes: