time value into database php syntax conversion error
So I am working on a way of transforming a timer which appears like this in HTML:
00:00:00
in hh/mm/ss - and I want to input it into my database but with it just as an integer value depicting the total seconds driven.
This is the method I have used to do this, where 'timedrive' is the form holding the time value, eg: "02:21:51".
$length = mysql_escape_string($_REQUEST['timeDrive']);
$parts = explode(":", $length);
$totalSeconds = parts[0] * 3600 + parts[1] * 60 + parts[2];
Nevertheless it is not working for what ever reason, I get this error:
Parse error: syntax error, unexpected '[' in /home/benjamin/public_html/elog/iframe/addtodatabase.php on开发者_Go百科 line 17
this is line 17:
$totalSeconds = parts[0] * 3600 + parts[1] * 60 + parts[2];
Thanks heaps for the help with this one!
You need a $
before your variable references:
$totalSeconds = $parts[0] * 3600 + $parts[1] * 60 + $parts[2];
精彩评论