我一直在扯头发,向众神献祭——做我能做的功课,但我和这里的其他两个帖子有同样的问题,这两个帖子似乎都没有解决
和
当我回显时,我得到了正确格式化的值我使用的是日期而不是日期时间 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;
?>