0

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
Lloyd

Edited by LloydFarrell: lef DOB our of query, still require help please

3
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by diafol
0

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,

VALUES('$securecode','$gender','$fname','$lname','$dob','$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....
lloyd

0

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).

Edited by darkagn: n/a

0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.