I'm getting the following query error.
$total = $wpdb->get_var("SELECT COUNT(*) FROM tsk_users_ticket_infor WHERE ID = %d AND IDX = %d", $user_ID , $id);
How would I go about replacing this system, without putting the variables directly in the query?
CodePudding user response:
You need to use placeholders, like WordPress recommends you need to prepare the statement on the get_var
$total = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM tsk_users_ticket_infor WHERE ID = %d AND IDX = %d", $user_ID , $id));
An insecure and not recomended way would be to use the variables in the string
$total = $wpdb->get_var("SELECT COUNT(*) FROM tsk_users_ticket_infor WHERE ID = $user_ID AND IDX = $id");