<?php 
define('DB_SERVER', '');
define('DB_USERNAME', '');
define('DB_PASSWORD', '');
define('DB_NAME', '');
 
/* Attempt to connect to MySQL database */
$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
 
// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}
 $msg = 'There are open tickets in SYSDesk!';

$sql = "SELECT * FROM tickets";
if($result = mysqli_query($link, $sql)){
    if(mysqli_num_rows($result) > 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);
            }
?>