我读了很多关于通过php在ms-access中插入日期的文章。但是,根据他们的建议,我必须在插入日期时使用。然而,php中的用于注释一行代码。我现在的问题是,我无法在数据库中插入/更新日期。
session_start();
$blnPage = $_SESSION['blnCount'];
try{
if ($blnPage == "EAP"){
if (isset($_POST['AudPlanNo']) && !empty($_POST['AudPlanNo'])){
$txtAPNo = trim($_POST['AudPlanNo']);
$txtAPUnivNo = trim($_POST['AudUnivNo']);
$txtAPBackground = trim($_POST['APBackground']);
$txtAPCoverage = trim($_POST['APCoverage']);
$txtAPObjective = trim($_POST['APObjective']);
$txtAPMethodology = trim($_POST['APMethodology']);
$txtAPWTManhours = trim($_POST['APWTManhours']);
$txtAPWTDate2 = strtotime($_POST['dWTDate']);
$txtAPWTDate = date("m-d-Y",$txtAPWTDate2);
$txtAPFWManhours = trim($_POST['APFWManhours']);
$txtAPFWDate2 = strtotime($_POST['dFWTDate']);
$txtAPFWDate = date("m-d-Y",$txtAPFDate2);
$txtAPRTManhours = trim($_POST['APRTManhours']);
$txtAPRTDate2 = strtotime($_POST['dRTDate']);
$txtAPRTDate = date("m-d-Y", $txtAPRTDate2);
$dbPath = $_SERVER["DOCUMENT_ROOT"]."/msaccess/dbAMS.accdb";
if(!file_exists($dbPath))
{
die("database not found");
}
$dbh = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; Dbq=$dbPath; Uid=Admin; pwd=;");
$sql = "UPDATE tblAudPlan SET tblAudPlan.[Background] = '$txtAPBackground', tblAudPlan.[AudObjective] = '$txtAPObjective', tblAudPlan.[AudCoverage] = '$txtAPCoverage', tblAudPlan.[ApproachMethodology] = '$txtAPMethodology', tblAudPlan.[WTManhours] = '$txtAPWTManhours',tblAudPlan.[WTDate] = '#$txtAPWTDate#' WHERE tblAudPlan.[AudPlanNo] = '$txtAPNo'";
$result = $dbh->query($sql);
$row = $result->fetch();
echo 1;
}
else{
echo 0;
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
$dbh = null;
?>
这就是我显示代码的方式
">
我也试过“m-d-y”,“mm-dd-yyy”,但没有成功。我真的不知道现在该怎么办。
当我尝试在开头和结尾使用single时,我的代码将如下所示