0
我使用PHP/MySQL創建事件系統,我使用PHP將日期拼湊在一起形成一個字符串。我希望我的日期格式爲dd-mm-yy。我使用下面的代碼:PHP undefined offset
$title = $_POST['title'];
$title = htmlspecialchars($title);
$type = $_POST['evtype'];
$type = htmlspecialchars($type);
$evdesc = $_POST['evdesc'];
$evdesc = htmlspecialchars($evdesc);
$startdate = (isset($_POST['startdate'])) ? $_POST['startdate'] : '' ;
$starttime = $_POST['starttime'];
$starttime = htmlspecialchars($starttime);
$enddate = (isset($_POST['enddate'])) ? $_POST['enddate'] : '' ;
$endtime = $_POST['endtime'];
$endtime = htmlspecialchars($endtime);
$location = $_POST['location'];
$location = htmlspecialchars($location);
// assemble dates and times
list($startday, $startmonth, $startyear) = array_pad(explode('-', $startdate, 2), 2, null);
$evstart = '' . $startyear . '-' . $startmonth . '-' . $startday . ' ' . $starttime . '';
list($endday, $endmonth, $endyear) = array_pad(explode('-', $enddate, 2), 2, null); // explode("-", $enddate);
$evend = '' . $endyear . '-' . $endmonth . '-' . $endday . ' ' . $endtime . '';
// end assemble
然而,這個代碼不爆炸的數據,唯一的事情,帖子到數據庫後上「 - (一次在這裏)」
錯誤分別是:
注意:未定義抵消:2 calendar.php上線42
注意:未定義抵消:2 calendar.php在線45
你已經告訴你所訪問未定義的陣列,在線路42偏移和45何不你只是看看這些線路上有什麼,並嘗試調試它? – MightyPork
@MightyPork 42和45是兩個list()函數 – James