0){ while($row = mysqli_fetch_array($result)){ mail('J.vos@ictmaatwerk.com','Sample Form',$msg,); echo "Mail succesfully sent."; } mysqli_free_result($result); } else{ echo "No tickets were found."; } } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } ?>