title: how to check if mysql query return no result(record not found) using php?
body: <p>i am passing images file names via textarea to php script to find information about each image in mysql db .The problem is i am trying to output those image file names that not found in mysql db and inform the user which image file names not found in mysql. my current code fails to output those missing records in db but it correctly outputs information about those images found in db. could any one tell me what i am doing wrong ?</p>
  
  <pre><code>foreach ($lines as $line) {
  
  
  $line = rtrim($line);
  
  
  $result = mysqli_query($con,"SELECT ID,name,imgUrl,imgPURL FROM testdb WHERE imgUrl like '%$line'");            
  
  
  
   if (!$result) {
               die('Invalid query: ' . mysql_error());
              }
  //echo $result;
  
    if($result == 0) 
      {
  
         // image not found, do stuff..
        echo "Not Found Image:".$line; 
      }
  
  
  
  while($row = mysqli_fetch_array($result))
    {
    $totalRows++;
  
    echo "&lt;tr&gt;";
    echo "&lt;td&gt;" . $row['ID'] ."(".$totalRows. ")&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['name'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['imgPURL'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['imgUrl'] . "&lt;/td&gt;";  echo "&lt;/tr&gt;";
  
  
  }
  
  };
  
  echo "&lt;/table&gt;";
  
  echo "&lt;br&gt;totalRows:".$totalRows;
  </code></pre>