<?php

function validateDate($date, $format = 'Y-n-j')
{
    $d = DateTime::createFromFormat($format, $date);
    // The Y ( 4 digits year ) returns TRUE for any integer
    // with any number of digits so changing the comparison
    // from == to === fixes the issue.
    return $d && $d->format($format) === $date;
}

# Cheung: Step 1: connect to DB

// first of all set PHP error reporting in general
// in order to be sure we will see every error occurred in the script
ini_set('display_errors',1);
error_reporting(E_ALL);

/*** THIS! ***/
# mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
/*** ^^^^^ ***/

if (!function_exists('mysqli_init') && !extension_loaded('mysqli'))
{
   echo "We don't have mysqli!!!\n\n";
   exit(1);
}

$con = new mysqli("localhost", "cheung", "wijs04heid", "warmhouse");
# $con = new mysqli("localhost", "root", "", "warmhouse");

if ($con->connect_errno)
{
    printf("connection failed: %s\n", $con->connect_error());
    exit();
}

?>
