How do I use a database in a custom theme?

Alright, You did not mention if that data will be stored upon submission from front end or you want to manually put that in. But lets see the way I would handle form submissions and store email addresses. I would use contact form 7 along with its addon Flamingo. It will let you store all … Read more

How to escape percentage sign(%) in sql query with $wpdb->prepare?

This is an incorrect use of prepare, that function is used to safely insert variables into queries. However the code in your question does this beforehand, bypassing the security function. E.g. What you did: $unsafesql = “INSERT $dangerousvariable”; $still_unsafe_sql = $wpdb->prepare( $sql, ” ); What it should be: $safe_sql = $wpdb->prepare( “INSERT %s”, $dangerousvariable );