Skip to content Skip to sidebar Skip to footer

Wpdb Prepare Was Called Incorrectly

I want to prepare my data to avoid SQL Injections. So my current working code to show a list of data from a table's column: global $wpdb; $sliders = $wpdb->get_results('SELECT a

Solution 1:

The prepare method is used to protect against SQL injection. You'd use it when you want to insert variables into your query. It accepts placeholders such as %s for string, %d for integers and %f for floats.

Your query doesn't have any variables so you don't need the prepare method. You're seeing an error because you aren't using any placeholders.

https://codex.wordpress.org/Class_Reference/wpdb#Protect_Queries_Against_SQL_Injection_Attacks

Post a Comment for "Wpdb Prepare Was Called Incorrectly"