473,396 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Inserting a date from form into mysql server.

2
I'm trying to insert date of birth from users into the MySQL database. However when I try to insert into the database it comes up with dateofbirth '0000-00-00'. The age function does work and it is just the date of birth field that won't function. It will still let me add the remaining fields. I tried $datetime1 as a way of using

Expand|Select|Wrap|Line Numbers
  1. $dateofbirth = $year .'-'. $month .'-'. $day;
  2. $date = date("Y-m-d");
  3. $datetime1 = date_create($dateofbirth);
  4. $datetime2 = date_create($date);
  5. $interval = date_diff($datetime1, $datetime2);
  6. $age = $interval->format('%y');
  7.  
  8. $update = mysql_query("UPDATE users SET dateofbirth = '$dateofbirth', age = '$age' WHERE uid = '$uid'");
  9.  
May 4 '15 #1

✓ answered by Dormilich

check what $dateofbirth’s value is to verify it’s a valid MySQL date.

1 1649
Dormilich
8,658 Expert Mod 8TB
check what $dateofbirth’s value is to verify it’s a valid MySQL date.
May 5 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tapio Kelloniemi | last post by:
Hi I'm a PHP and MySQL newbie, but know something about Unix-like systems. I need to install PHP and MySQL for a person using GNU/Linux server. This server is not however his and the service...
1
by: Jim Johnson | last post by:
Will a .NET application run on a MySQL server? I know I can access MySQL tables by using the leDbDataAdapter, but will the server handle the .Net aspx and ado code? Must the server have IIS...
2
by: avinash | last post by:
hello myself avinash i am developing on application having vb 6 as front end and sql server 7 as back end. when i use insert query to insert data in table then the date value of that query is...
1
by: Michael Albanese | last post by:
I am building an application to report on-the-job injuries and incidents. There are a lot of Date fields, some of which are optional and can be left blank by the user. I have allowed Nulls on...
6
by: Raqueeb Hassan | last post by:
Hello There! Have you guys tried inserting variables in mySQL tables? Do I have to use 'quote' as we had been doing to insert strings? mysql> INSERT INTO occurrence (word_id,page_id) VALUES...
15
by: Khurram | last post by:
I have a problem while inserting time value in the datetime Field. I want to Insert only time value in this format (08:15:39) into the SQL Date time Field. I tried to many ways, I can extract...
0
by: Philip Dennis | last post by:
Dim idate As Date Dim DbDate As Date I have these defined on an application that reads a flat file to update a Sql 2005 Beta 2 database. The first record of the file always will contain a...
2
by: Kun | last post by:
I have an html form that takes dates and inserts them into a mysql file. Currently, users have to type in dates in the yyyy-mm-dd format. As of now, this process works with the sql. However, I...
2
by: Paul | last post by:
I'm sure this isn't a difficult question, but I've been struggling trying to insert the current date into a sql server field. I've tried numerous suggestions that I've seen in newsgroups and...
1
by: Abhinay | last post by:
hi, I have created echo server whose task is to receive client request using socket and make inset into mysql database, for database connection I have use 'Mysql C' library, my server have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.