Hi all, I have a form that works great, thats updates mysql db\table But id like the end user to enter his/her D.O.B.

for that I have created 3 dropdown menus one for day, second for month and third for year..since I'm new to php Id like to understand \ learn more about concatination

the fields are called dob_d \ dob_m \ dob_y

$gender = clean($_POST['gender']);
	$fname = clean($_POST['fname']);
	$lname = clean($_POST['lname']);
	$dob_y = clean($_POST['dob_y']);
	$dob_m = clean($_POST['dob_m']);
	$dob_d = clean($_POST['dob_d']);

I have tried several combinations of the above ie.
dob_y \ dob_m \ dob_d

the database field is named "dob"

$dob_db = "$dob_y-$dob_m-$dob_d";
iv also tried 
$dob_db = "$dob_y." ".$dob_m." ".$dob_d";
$qry = "INSERT INTO users(securecode, gender, firstname, lastname, dob, age, login,) VALUES('$securecode','$gender','$fname','$lname','$dob','$age','$login')";

its driving me crazy, Hope someone can help me out on this, and provide a learning curve, not just for me, but for those who may be looking for the same type of solution.
be regards

HI all,

iv been trying a few different things with this dob but im still getting erros

when i try

$dob_db = "$dob_y. "/" .$dob_m. "/" .$dob_d";

$qry = "INSERT INTO members3t(securecode, gender, firstname, lastname, dob_y, dob_m, dob_d, age,


i get the following error message "Warning: Division by zero in "

if i try this

$dob_db = "$dob_y." ".$dob_m." ".$dob_d";

i get the following error message Parse error: syntax error, unexpected '"'
anyone got any help....

All dates in MySQL are in the format: yyyy-mm-dd. Notice the hyphens and the number of digits ie 4 for the year, 2 for the month and 2 for the day. Today's date would be entered as 2009-12-24 and New Years Day would be entered as 2010-01-01.

That said, if your dob is a single date field, then your query should look something like this:

insert into members3t (securecode, gender, firstname, lastname, dob, age) 
values ('$securecode','$gender','$fname','$lname','$dob','$age')

Notice that the number and order of columns in the insert part of the query must match the number and order of columns in the values part of the query, and all opened brackets must be closed (balanced).

Member Avatar

Twopenneth worth:

I hate the VALUES syntax 'coz I always mess up the order or the number of values to my fields. Perhaps the SET syntax is easier?