$wpdb select prepare statement

I am stuck on fixing a serious issue that took too much time than it should. I know it might be a small thing, but i spent too much time only to create a simple select query. Here is the code i am using to look at and tell me what is going wrong.

global $wpdb;
    $querystr = "
    SELECT $wpdb->posts.ID 
    FROM $wpdb->posts
    WHERE $wpdb->posts.post_type = 'product'
    AND $wpdb->posts.post_title = $tour_name

$productids = $wpdb->get_results($querystr, OBJECT);

foreach ($productids as $productid) {
echo $productid;

Read more here: $wpdb select prepare statement

Leave a Reply

Your email address will not be published. Required fields are marked *