Don't Give mysql to change date format. Do it by your PHP code.
$a = !empty($_POST['var1']) ? $_POST['var1'] : null;
$b = !empty($_POST['var2']) ? date('d/m/Y', strtotime($_POST['var2'])) : null;
$sqlQuery = "Insert into abc(a,b) values('$a','$b')";
manpreet
Best Answer
2 years ago
I am trying to insert data into a
MySql
database with the query below.I get this error
How can I default both
a
andb
toNULL
when the variable values are missing.