 <p>correct code can be</p> <pre><code>echo "SELECT * FROM `active_customers` WHERE `cus_email`='".$k."' AND `cus_product`='".$_GET['product']."'" . "&lt;br /&gt;"; $q = mysql_query("SELECT * FROM `active_customers` WHERE `cus_email`='".$k."' AND `cus_product`='".$_GET['product']."'"); $n = mysql_num_rows($q); echo "Number of rows:" . $n; while($row = mysql_fetch_array($q, MYSQL_ASSOC)){ echo $row['cus_id']; echo $row['cus_email']; } </code></pre> <p>Although i would recommend using mysqli or PDO for sql databases</p>