Null when update Date field - MySQL PHP -
i'm trying update date field in db. query this:
$q = "update news set data = str_to_date('2011-03-05','%y-%m-%d'), title = '".$title."', content='".$content."',....";
works great, but:
$q = "update news set data = str_to_date('".$data."','%y-%m-%d'), title = '".$title."', content='"...";
it not working :(
i got date:
$data = $_post["data"];
and has value "2013-04-13". trimmed date , show in popup window , value correct; plz :)
update strange me, if i'm using:
$q = "insert news set data = cast('".$data."' date), title = '".$title."', content='".$content."'...";
it works fine. in insert not in update
script table:
create table if not exists `news` (`id` int(11) not null auto_increment, `data` date not null, `title` text not null, `content` text not null, `img` text not null, `n_img` text not null, primary key (`id`), key `id` (`id`)) engine=myisam default charset=utf8 auto_increment=36 ;
why using str_to_date
? looks date in correct format. try removing , inserting is?
might want escape first though.
$data = mysql_real_escape_string($_post["data"]);
Comments
Post a Comment