Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource [duplicate]



PHP Snippet 1:

$result = mysql_query ($query) or die(mysql_error());

PHP Snippet 2:

$query = "SELECT us.users_id, us.users_first_name, us.users_surname, us.users_business, 
             ord.order_id, ord.users_id, ord.total, ord.order_date,  
             oc.oc_id, oc.order_id, oc.products_id, oc.quantity, oc.price/*here*/,/**/
             prd.products_id, prd.products_name, prd.price      
         FROM users AS us, orders AS ord, order_contents AS oc, products AS prd  
         WHERE ord.order_id=$id
         AND us.users_id = ord.users_id
         AND ord.order_id = oc.order_id
         AND oc.products_id = prd.products_id    
         ";

PHP Snippet 3:

if (!mysql_query($query, $link)) {
    echo mysql_errno($link) . ": " . mysql_error($link) . "\n";
}

PHP Snippet 4:

if (!$result)
{
  // error
}
else
{
  // use results
}

PHP Snippet 5:

 $result = mysql_query ($query) or trigger_error(mysql_error(),E_USER_ERROR);