我試圖在特定日期範圍內獲取表格時似乎遇到問題。這是我的PHP代碼。我嘗試使用BETWEEN和< =來獲取日期範圍,但它似乎不起作用。當我將結果打印到控制檯時,我只是得到一個Uncaught SyntaxError:意外的數字。有什麼建議麼?MySQL和PHP的日期範圍
if($_POST['subdate'] != "")
{
$sdate = dateClean($_POST['subdate']);
$edate = dateClean($_POST['subdateend']);
if($checkWhereVar==0)
{
if($_POST['subdateend'] != "")
{
$longQuery.= "SubmissionDate >= '".$sdate."' AND SubmissionDate <= '".$edate."";
echo ("<script>console.log('$longQuery')</script>");
}
else{
$date = date('Y/m/d H:i:s');
$edate = $date;
$longQuery.= "SubmissionDate >= '".$sdate."' AND SubmissionDate <= '".$edate."";
}
//$longQuery.= " SubmissionDate BETWEEN = '".$sdate."'";
$checkWhereVar = 1;
}
else
{
$date = date('Y/m/d H:i:s');
$edate = $date;
echo ("<script>console.log('in sub date else')</script>");
$longQuery.= "SubmissionDate >= '".$sdate."' AND SubmissionDate <= '".$edate."";
}
$filter .= " Submission Date: <i>".$_POST['subdate']."</i>";
}
**警告**你不應該滾動自己的SQL注入保護! –
在執行併發布之前立即回顯查詢。 –
「Uncaught SyntaxError」其中和全部細節。 – JakeGould