I have a problem with inserting data. When I leave a field empty then he writes a 0 in my db instead of 0. What I have to do that he writes NULL.
<?php
if ($date == '' || $name_home == ''|| $name_away == '')
{
$error = 'Please enter the details!';
valid($date, $name_home, $name_away, $score_home, $score_away, $error);
}
else
{
mysql_query("INSERT name_matches SET date='$date', name_home='$name_home', name_away='$name_away', score_home='$score_home', score_away='$score_away'")
or die(mysql_error());
header("Location: view.php");
}
}
else
{
valid('','','','','','');
}
?>
Aucun commentaire:
Enregistrer un commentaire