(Despite being a different language and RDBMS, this is the same problem as in this question.)
Firstly, SQL strings must be contained in ''
: you're clearly missing them in (".$user['birthday'].' ...
. Secondly, and more importantly, they must be escaped, to prevent SQL injection attacks (and to make sure the string is valid anyway).
In general, it's better to use prepared statements to pass the parameters to SQL query instead of inserting the variables in the query itself: this should take care of the escaping and conversion for you.
You'll also need to cast the birthday string into a date if necessary.
I'd recommend using mysqli
and prepared statements instead. (There are a number of examples out there, perhaps this would help.)
EDIT:
Try something along these lines perhaps (assuming you've switched to mysqli
):
$query = "insert into table (birthday,currenttime) values (STR_TO_DATE(?, '%m/%d/%Y'), CURDATE())";
if ($stmt = $mysqli->prepare()) {
$stmt->bind_param('s', $user['birthday']);
$stmt->execute();
$stmt->close();
} else {
die($mysqli->error);
}
(This might need to be birthday_date
as Jeroen suggested too.)