What are the potential consequences of not running MySQL in Strict mode when working with PHP?

Running MySQL in non-Strict mode can lead to potential data integrity issues, as it allows for invalid or incomplete data to be inserted into the database. To solve this, it is recommended to enable Strict mode in MySQL to enforce stricter data validation rules.

// Enable Strict mode in MySQL
$sql = "SET GLOBAL sql_mode='STRICT_ALL_TABLES'";
$result = mysqli_query($conn, $sql);

if ($result) {
    echo "Strict mode enabled in MySQL";
} else {
    echo "Error enabling Strict mode in MySQL: " . mysqli_error($conn);
}