无法使用php更新mysql中的日期类型

I am trying to retrieve the date of birth from users once they submit the form and update the date type, but I am unable to update the date type. Can you tell me what I am doing wrong?

if($_POST){
    $dob = date('Y-m-d',strtotime($_POST['year']."-". $_POST['month']."-".$_POST['day'])); 

    $retur = $userObj->updateProfile($dob);
}

 public function updateProfile($dob){
$db = db_mysql::getInstance();
$qr = $db->query("UPDATE ".USERS." SET dob = $dob WHERE id = '".$udata."'") or die(mysql_error()); 

        return $udata;
}

Try this:

$qr = $db->query("UPDATE ".USERS." SET dob = '$dob' WHERE id = '".$udata."'") or die(mysql_error());

You should look at using bound parameters, though - it avoids this sort of thing, as well as making your code a lot more secure.

Editted to add:

The manual page on binding parameters has a few very useful examples.

Put quotes around the date, now the statement looks like

UPDATE USERS SET dob = 01-02-2012 WHERE id = 'x'

The date in this case is seen as a number (-2013, I think). ;)

Even better: Use prepared statements (search for PDO) and pass the date in a date parameter.

What is $udata and where are you getting it from?

If it is a class property then you need to call it with $this->udata or $db::udata in this case since you seem to be calling a static class or perhaps pass it in to the function if it is neither of these.

Also why is your query "UPDATE ".USERS." SET dob = $dob WHERE id = '".$udata."'", what is happening with USERS? Sure it should just be "UPDATE USERS SET dob = '$dob' WHERE id = '".$udata."'" and add the '' around $dob as mentioned previously.