Having problems inserting MM-DD-YYYY to Y-m-d (MySql default
format). After many hours of frustration, I purchased the
Developer's toolbox thinking it would handle this automatically.
yes, very funny. The Developer toolbox control panel requires the
date format setting for database format and screen format. I used
the Date picker form control to insert a date, but it errors on
insert (putting 0000-00-00 instead of the actual date inserted).
Does anyone have suggestions on how to convert the date to
Y-m-d?
Here's the insert code (using an extension that allows
inserting of multiple rows using repeat region) Trying to get the
delduedate formatted as Y-m-d. Thanks in advance.
// *** FX Insert Multiple Records RL in add_deliverable
if (isset($startRow_deliverabletype)) $ins_deliverabletype =
$startRow_deliverabletype; else $ins_deliverabletype = 0; //
counter
if (isset($_POST['Submit'])) {
$FX_sqlerror = "";
$FX_insredir = "view_conf_event.php";
$FX_fields =
array("deltypeid","eventid","delduedate","delstatusid","delassignee","delnotes");
$FX_altv = false;
mysql_select_db($database_eventtracker, $eventtracker);
for ($N=$ins_deliverabletype+1;
$N<=$totalRows_deliverabletype; $N++) {
$found = false;
for ($i=0; $i<sizeof($FX_fields); $i++) {
if ((isset($_POST[$FX_fields[$i].$N]) &&
$_POST[$FX_fields[$i].$N] != "") || $FX_altv) {
$found = true; break;
}
}
if ($found) {
$mIns_SQL = sprintf("INSERT INTO deliverables (deltypeid,
eventid, delduedate, delstatusid, delassignee, delnotes) VALUES
(%s, %s, %s, %s, %s, %s)",
isset($_POST["deltypeid$N"]) ? ($_POST["deltypeid$N"] != ""
? ("".addslashes(stripslashes($_POST["deltypeid$N"]))."") : "NULL")
: "0",
isset($_POST["eventid$N"]) ? ($_POST["eventid$N"] != "" ?
("".addslashes(stripslashes($_POST["eventid$N"]))."") : "NULL") :
"0",
isset($_POST["delduedate$N"]) ? ($_POST["delduedate$N"] !=
"" ? ("'".addslashes(stripslashes($_POST["delduedate$N"]))."'") :
"NULL") : "''",
isset($_POST["delstatusid$N"]) ? ($_POST["delstatusid$N"] !=
"" ? ("".addslashes(stripslashes($_POST["delstatusid$N"]))."") :
"NULL") : "0",
isset($_POST["delassignee$N"]) ? ($_POST["delassignee$N"] !=
"" ? ("'".addslashes(stripslashes($_POST["delassignee$N"]))."'") :
"NULL") : "''",
isset($_POST["delnotes$N"]) ? ($_POST["delnotes$N"] != "" ?
("'".addslashes(stripslashes($_POST["delnotes$N"]))."'") : "NULL")
: "''",
"");
$mIns_Result = mysql_query($mIns_SQL, $eventtracker) or
$FX_sqlerror .= "Row ".$N.": " . mysql_error() .
"<br><br>";
}
}
if ($FX_insredir == "") $FX_insredir =
basename($_SERVER['SCRIPT_NAME']);
if (isset($_SERVER['QUERY_STRING'])) {
$FX_insredir .= (strpos($FX_insredir, '?')) ? "&" : "?";
$FX_insredir .= $_SERVER['QUERY_STRING'];
}
if ($FX_sqlerror != "") {
echo '<font
color="red">'.$FX_sqlerror.'</font>';
} else header("Location: " . $FX_insredir);
}