Date field not accepting value

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Bobo the Bugbear
Forum Newbie
Posts: 4
Joined: Sun Jul 18, 2004 1:43 am

Date field not accepting value

Post by Bobo the Bugbear »

feyd | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


I pull the date (ex September 13, 2004) inputted into a box from a form. This is called $tdate. I then break this up to get the month, day & year to input into the DB. The DB (MysQL) field is a date (format is 0000-00-00) type. When the input code is executed all values but the date are placed into the DB even though it is specified to do so. The value to be inputted is $completeDate. When I echo it, I get the correct date in the format 0000-00-00.  Anyone see what may be the cause of the date not being inputted?

Code: Select all

$getDate = explode(" ", $tdate);
$month = array_slice($getDate,0,1);
$year = array_slice($getDate,2,2);

$getDay = explode(",",$tdate);
$dayO = array_slice($getDay,0,1);

$dayN = explode(" ",$dayO[0]);
$day = array_slice($dayN,1,1);

$newMonth = date("m", mktime(0, 0, 0, $month[0], 0, $year[0]));
$completeDate = date("Ynm", mktime(0, 0, 0, $month[0], $day[0], $year[0]));

//1 - normal
//2 - urgent

if ($id == 0) {

$runQuery ("INSERT INTO todo (name, description, date, time, priority, month, year, finished)".
"VALUES ('$name', '$message', $completeDate, '$time', '$priority', '$newMonth', '$year[0]', 1)");
Don't comment on the $runQuery. This has been defined in a global file & is accurate.


feyd | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

Post by fresh »

could you use UPDATE instead of INSERT?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

post the rendered query line please.
Bobo the Bugbear
Forum Newbie
Posts: 4
Joined: Sun Jul 18, 2004 1:43 am

Post by Bobo the Bugbear »

what is a "rendered query line"
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

echo the query string
Post Reply