I am attempting to use $wpdb->prepare to protect against SQL injection attacks and am lost. I have the following snippet below which checks the h_transactions table for a transaction id. If it doesn't find the id then it adds it to the table...
<?
global $wpdb;
$table_name = $wpdb->prefix . "h_transactions";
$registered = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name WHERE transactionid = '{$transactionid}'" );
if ($registered == 0) {
$wpdb->insert( $table_name, array( 'transactionid' => $transactionid ), array('%s') );
}
else
?>
Do I need to use $wpdb->prepare on both the SQL query and the SQL insert?
$transactionid
come from?