I have 3 combo boxes for DOB on my form in this order DAY MONTH YEAR
What order should the red parts be in (and also is the orange part correct)
$DOB=date("Y-m-d",mktime(0,0,0,$_POST['DOBmm'],$_POST['DOBdd'],$_POST['DOByyyy']));
Here is part of my code (i know it's wrong because i dont have the above red parts in it, but i am not sure where the above red parts should be in the code below and i'm not sure what order they should be in)
This part stays the way it is:$DOB=date("Y-m-d",mktime(0,0,0,$_POST['DOBmm'],$_POST['DOBdd'],$_POST['DOByyyy']));
And this part needs to look like this:mysql_query("INSERT INTO accounts
(firstname, lastname, username, password, dob, gender, county, college, email, photo) VALUES( '$firstname' , '$lastname' , '$username', '$password', '$DOB', '$gender', '$county', '$college', '$email', '$photo') ");First, the variable $DOB is created using the three date parts and then it is inserted as one in the table.
oo7ml
01-18-2007, 10:06 AM
It's still not showing up in my database
Can you see where i am going wrong, thanks for your help
<?php
//retrieve form data in a variable
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$username = $_POST['username'];
$password = $_POST['password'];
$dob = date("Y-m-d", mktime(0,0,0,$_POST['DOByear'],$_POST['DOBmonth'],$_POST['DOBday']));
$gender = $_POST['gender'];
$county = $_POST['county'];
$college = $_POST['college'];
$email = $_POST['email'];
$photo = $_POST['photo'];
// Make a MySQL Connection
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("one") or die(mysql_error());
// Insert a row of information into the table
mysql_query("INSERT INTO accounts
(firstname, lastname, username, password, dob, gender, county, college, email, photo) VALUES( '$firstname' , '$lastname' , '$username', '$password', '$DOB', '$gender', '$county', '$college', '$email', '$photo') ");
?>
/////////////////////////////////////////////////////////////////////////
My field in my database is called: dob
/////////////////////////////////////////////////////////////////////////
This part:mysql_query("INSERT INTO accounts
(firstname, lastname, username, password, dob, gender, county, college, email, photo) VALUES( '$firstname' , '$lastname' , '$username', '$password', '$DOB', '$gender', '$county', '$college', '$email', '$photo') ");needs to look like this:$sql = "INSERT INTO accounts
(firstname, lastname, username, password, dob, gender, county, college, email, photo) VALUES( '$firstname' , '$lastname' , '$username', '$password', '$DOB', '$gender', '$county', '$college', '$email', '$photo') ";
mysql_query($sql) or die("SQL Error: $sql<br>" . mysql_error());Also, in a separate thread I posted a function to escape all database fields prior to inserting in the database. At a minimum, use addslashes() or better mysql_real_escape_string().
webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved.