ketting00 — 2011-07-28T12:46:35-04:00 — #1
I have a problem with inserting specific time into Mysql database using a form bellow:
<form method="post" action="insert_time.php">
<input type="time" name="time">
<input type="submit" value="Insert Time">
When I input data such as 12:00:00, the value is invalid. How to overcome this problem?
r937 — 2011-07-28T12:47:58-04:00 — #2
we would need to see the table definition (do a SHOW CREATE TABLE in mysql) as well as the insert_time.php code
ketting00 — 2011-07-28T13:09:11-04:00 — #3
thanks for response, here is it:
$mysqli->query("DROP TABLE IF EXISTS video;") or die("DB error");
$mysqli->query("CREATE TABLE `video` (
`vdo_id` INT NOT NULL AUTO_INCREMENT,
`vdo_path` VARCHAR( 120 ) NOT NULL ,
`time` TIME NOT NULL default '00:00:00',
`title` VARCHAR( 75 ) NOT NULL ,
PRIMARY KEY ( `vdo_id` ) ,
) ENGINE = INNODB
or die("DB error!");
and the insert.php
$title = trim($_POST['title']);
$time = trim($_POST['time']);
$vdo_path = basename($title.$length);
$mysqli->query("INSERT INTO video(vdo_path, time, title) VALUES('$vdo_path','$time','$title');") or die(mysqli_error());
r937 — 2011-07-28T13:23:39-04:00 — #4
this does not explain why the time value is not working
could you please echo the php query before executing it
in other words, we need to see the contents of '$time' that mysql sees
ketting00 — 2011-07-28T13:42:00-04:00 — #5
I have no idea. It just didn't work since the <input type="time" name="time">.
The form didn't pass the value from the input field. The value is blank and it didn't pass the if(empty($_POST['time']) check.
Additionally, when you use Google chrome it pops up an alert message of 'Invalid Value'.
Is I use the incorrect form?
spacephoenix — 2011-07-28T13:56:59-04:00 — #6
A quick search shows the input type "time" to be HTML5, try switching the input type of the form to "text"