jim.davidson Posted October 25, 2007 Share Posted October 25, 2007 I've been looking at this for the past couple of hours trying to figure out what I'm doing wrong, but I can't see it. I'm trying to update a date of birth field in a table from user input but it doesn't update dob. What am I doing wrong? variable from input form $dob = '10/15/1951' $ddate = explode('/', $dob); $sql_dob = "$ddate[2]-$ddate[0]-$ddate[1]"; Here's the php code to update $patientid = $_SESSION['patient_id']; $updateSQL = "UPDATE patient SET dob = $sql_dob WHERE patient_id = $patientid"; mysql_select_db($database_pnurse, $pnurse); $Result1 = mysql_query($updateSQL, $pnurse) or die(mysql_error()); Here's the table info Table patient Field Type Null Default dob date No 0000-00-00 Quote Link to comment https://forums.phpfreaks.com/topic/74787-solved-updating-a-date-field/ Share on other sites More sharing options...
fenway Posted October 25, 2007 Share Posted October 25, 2007 Missing quotes? Echo the $updateSQL. Quote Link to comment https://forums.phpfreaks.com/topic/74787-solved-updating-a-date-field/#findComment-378115 Share on other sites More sharing options...
jim.davidson Posted October 25, 2007 Author Share Posted October 25, 2007 Here's what i get when I echo $updateSQL UPDATE patient SET dob = 1951-10-15 WHERE patient_id = 8 Quote Link to comment https://forums.phpfreaks.com/topic/74787-solved-updating-a-date-field/#findComment-378120 Share on other sites More sharing options...
fenway Posted October 25, 2007 Share Posted October 25, 2007 That's what I thought... dates are string literals, wrap in single quotes. Quote Link to comment https://forums.phpfreaks.com/topic/74787-solved-updating-a-date-field/#findComment-378132 Share on other sites More sharing options...
jim.davidson Posted October 25, 2007 Author Share Posted October 25, 2007 Thank you very much, that was it! Quote Link to comment https://forums.phpfreaks.com/topic/74787-solved-updating-a-date-field/#findComment-378136 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.