私は髪を引き裂き、神々に犠牲を捧げてきました-そして、できる限りの宿題をしていますが、ここにある他の2つの投稿と同じ問題を抱えていますが、どちらも未解決のようです
適切にフォーマットされた MySQL 日付挿入ステートメントはすべて 0 を返します
と
MYSQL 日付フィールドは常に 0000-00-00 を出力します
エコーすると、適切にフォーマットされた値が得られます DATETIME ではなく Date を使用しています MySQL は日付の前に適切に名前を入力しますが、空白の longblob (画像) も入力しますMySQL を適切にセットアップしましたか、それとも何か他のことをしましたか?
私のコードは
catch(PDOException $e)
{
echo "Im sorry dave I cant do that";
echo $e->getMessage();
}
//*next bit is to insure that if connection is lost database is not
partially updated-I think-
//* $DBHandle->beginTransaction();
$firstnameOBS= $_POST['touristfirstname'];
$todaysdateOBS= $_POST['touristdatetoday'];
$picturenow= $_POST['picturesubmitted'];
$JSONfirstname = json_encode($firstnameOBS);
$JSONtodaysdate = json_encode($todaysdateOBS);
$JSONpicturenow = json_encode($picturenow);
echo $JSONtodaysdate ;
//* Below is the send from PHP page to My Sql Server -
//* JSON encode here
try {
$senditin = $DBHandle->prepare("INSERT INTO
`Observations`.`fkarnd`(`firstname`,`datetoday`,`picturesubmitted`) VALUES
(:firstname
, :datetoday ,:picturesubmitted)", array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
//* $senditin->bindValue(':firstname', $JSONfirstname, PDO::PARAM_STR);
//* $senditin->bindValue(':datetoday', $JSONtodaysdate, PDO::PARAM_STR);
//* $senditin->bindValue(':picturesubmitted', $JSONpicturenow,
PDO::PARAM_LOB);
//* $myinputarray = array('firstname'=> $JSONfirstname, 'datetoday' =>
$JSONtodaysdate, 'picturesubmitted' => $JSONpicturenow );
$DBHandle->beginTransaction();
$senditin->execute(array('firstname'=> $JSONfirstname, 'datetoday' =>
$JSONtodaysdate, 'picturesubmitted' => $JSONpicturenow ));
//* commit allows transaction begun to complete
$DBHandle->commit();
}
catch ( PDOException $e ) {
echo "I'm sorry, I can't do that Dave......";
file_put_contents( 'dbErrors.txt', $e->getMessage(), FILE_APPEND );
//* rollback function call here? a nasty exception has appeared,
}
echo "<br>"."successful submission";
$DBHandle = null;
?>