473,386 Members | 1,647 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,386 software developers and data experts.

text to date and insert to mysql...

Kindly break out the 4x2 and bring me to my senses.
I seem to have gotten myself totally confused with php.net, mysql.org pages
on dates etc, as well as groups.google.

Could someone explain, even using pseudo code, how to take a text input I
have set up as YYYY-MM-DD using php, and convert to a value mysql will
insert into a Date (not timestamp, not datetime) field.

Kind regards,
and thanks in advance,
PhilM
Jul 16 '05 #1
1 7640

"Roger Smith" <roger@ns_jadebox.com> wrote in message
news:9i*******************@twister.tampabay.rr.com ...
Could someone explain, even using pseudo code, how to take a text input I have set up as YYYY-MM-DD using php, and convert to a value mysql will
insert into a Date (not timestamp, not datetime) field.
MySQL has no problem with dates in "YYYY-MM-DD" format.

For example,

$result = mysql_query("insert into test (created) values

('2003-07-11')");
-- Roger
http://www.harrynilsson.com/

Yes, I know. I did mention a lump of 4x2...

My prblem was not the format after all(obiously), but the way I was trying
to check if the date had already been entered.
What I tried to do, was use in_array, to compare my date with those already
in the table.
(I didn't realize that it wouldn't work unless using strict, which I have
not yet understood in full)
This then had me Assuming I had the format wrong ;)
Ended up using:

$queryNewTest = "select compDate from tbl_competition where compDate =
'$concatDate'";
$resultNewTest = mysql_query($queryNewTest) or die("Query failed
:-".MYSQL_ERROR());
$numNewRows = mysql_num_rows($resultNewTest);
$textNewDate = formatdate($concatDate);
if ($numNewRows){
$newTextAlert = " <b class=\"alert\">$textNewDate</b> already exists";
echo $newTextAlert;
}
else {
$newOkDate = "Will enter $textNewDate into system.";
echo $newOkDate;
}

$concatDate is my string taken from 3 text boxes, checked, and joined.
formatdate() is a function found on php.net user comments, and turns date
into format
Tuesday, 22 Apr 2003

else section will ultimately contain insert statement... but not this
morning, 2:15am... I'm going to bed.

Thanks for replying.
Regards
PhilM
Jul 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Ethan | last post by:
Im doing perl for an online store and wondering if someone knew a way (a script) to get my text files in to my database?
4
by: news | last post by:
Our production database in an exported textfil runs about 60 MB. Compressed that's about 9 MB. I'm trying to import the export into another machine running FC3 and mySQL 11.18, and it appears as...
2
by: Paul | last post by:
I am trying to insert a date into a mysql table but everytime I attempt it the date field is always empty. The field is of Date type and the date in code is in European format dd/mm/yyyy. ...
8
by: libsfan01 | last post by:
how can i use regular expressions to ensure a mysql format date entry in a text field? thanks marc
1
by: jimmy | last post by:
I'm trying to insert a date into a MySQL date column. The string i am trying to insert takes the following format: 2007-02-23 which corresponds to the date format that MySQL uses which is...
6
by: marc | last post by:
hi im trying to convert Date() into a unix timestamp so i can stick the result into a mysql db, please help!
12
by: mantrid | last post by:
Hello Can anyone point me in the right direction for the way to read a text file a line at a time and separate the fields on that line and use them as data in an INSERT to add a record to a mysql...
2
by: zhusupe | last post by:
$sql_string="insert into article(title,content,class_id,post_time,post_time_year,post_time_month) values('".$title_article."','".$content_article."',1,".date('Y-m-j...
3
by: janetopps | last post by:
I have a news website, with asp pages, which was on Access, and i upgraded to MySQL, i used Bullzip to transfer the data. It had about 1000 pages, which im now able to pull up on the public side. Im...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.