我正在尝试将 html5 输入类型日期变量作为参数传递给存储过程。查询在我的php页面中成功执行,但存储过程插入的表中的列日期值标记为0000-00-00。
请告诉我哪里出错了。谢谢你的时间。
<?php include 'config.php';
if(isset($_POST['submitbtn'])){
$date = $_POST['datefield'];
$newDate = date("Y-m-d", strtotime($date));
$result = mysql_query("Call seat(".$newDate.")");
if($result == FALSE){
echo "Sorry Query Failed!";
}
else
{
echo "Success";
}
}
?>
<html>
<head>
</head>
<body>
<form method="post">
<input type="date" name="datefield"><br>
<input type="submit" name="submitbtn">
</form>
</body>
</html>
sql fn:
CREATE DEFINER=`root`@`localhost` PROCEDURE `seat`(IN `dateP` VARCHAR(20))
NO SQL
begin
declare i int default 1;
while i < 250 do
insert into seat (Seat_ID,dateP) values (i,dateP);
set i = i + 1;
end while;
end
座位表结构:
CREATE TABLE IF NOT EXISTS `seat` (
`ID` int(100) NOT NULL AUTO_INCREMENT,
`Seat_ID` int(4) NOT NULL,
`Row_ID` varchar(2) NOT NULL,
`Col_ID` int(4) NOT NULL,
`Amount` int(3) NOT NULL,
`DateP` date NOT NULL,
PRIMARY KEY (`ID`)
)