日期:2014-05-16  浏览次数:20739 次

日期的问题
DELIMITER   $$

DROP   PROCEDURE   IF   EXISTS   `cn1770724`.`insertarticle`   $$
CREATE   PROCEDURE   `insertarticle`(
$title   varchar(60),
$posttime   date,
$picpath   varchar(100),
$content   text,
$content_from   varchar(60),
$copyright   varchar(100),
$article_type   varchar(60),
$hits   int,
$adddate   date,
$typeid   int
)
BEGIN
insert   into   `article`
(`title`,
`posttime`,
`picpath`,
`content`,
`content_from`,
`copyright`,
`article_type`,
`hits`,
`adddate`,
`typeid`)
values   (
'$title ',
'posttime ',
'$picpath ',
'$content ',
'$content_from ',
'$copyright ',
'$article_type ',
'$hits ',
'$adddate ',
'$typeid ');
END   $$

DELIMITER   ;


call   insertarticle( 'dfjdjkj ',   '2007-07-24 ',   'dsdsds ',   'dsfdd ',   'dsdsds ',   'dsds ',   'sddsds ',   '3443 ',   '2007-07-24 ',   '23 ')
在执行的时候提示
#1292   -   Incorrect   date   value:   'posttime '   for   column   'posttime '   at   row   1
请问这是什么原因。
为什么在phpmyadmin   时候执行插入生成这条语句,在phpmyadmin   直接插入没有问题,到了过程里面就有了问题。   请大家帮帮忙

------解决方案--------------------
try:

DELIMITER $$

DROP PROCEDURE IF EXISTS `cn1770724`.`insertarticle` $$
CREATE PROCEDURE `insertarticle`(
$title varchar(60),
$posttime date,
$picpath varchar(100),
$content text,
$content_from varchar(60),
$copyright varchar(100),
$article_type varchar(60),
$hits int,
$adddate date,
$typeid int
)
BEGIN
insert into `article`
(`title`,
`posttime`,
`picpath`,
`content`,
`content_from`,
`copyright`,
`article_type`,
`hits`,
`adddate`,
`typeid`)
values (
'$title ',
'$posttime ',
'$picpath ',
'$content ',
'$content_from ',
'$copyright ',
'$article_type ',
'$hits ',
'$adddate ',
'$typeid ');
END $$

DELIMITER ;