Foreach loop using $wpdb not results from rows

First of all, you should never concatenate SQL Query with any variables this way – it will cause SQL Injection vulnerability.

Also… get_results method returns just an array of results. You can’t use it as an object and get num_rows from it – there is no such property in an array (it’s a property of WPDB object).

Another problem is that by default get_results will return selected rows in object format, not as arrays.

So here’s the fixed code:

<?php
    require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );

    global $wpdb, $ipONactivate;

    $ipn_table = $wpdb->prefix ."ipn_data_tbl";

    $result = $wpdb->get_results( $wpdb->prepare(
        "SELECT * FROM {$ipn_table} WHERE item_name = %s AND payer_email = %s",
        $product, $serial
    ) );

    if ( ! empty( $result ) ) {
        foreach($result as $row) {

            if ($row->item_name == $product && $row->payer_email == $serial) {
                echo true;
            } else {
                echo false;
            }
        }
    }
?>

BTW. You can trust the SQL. If you select only rows that has given product and serial, then you don’t have to loop through them and check if they are equal to given values.