[PHP] HOW update time and date-fields to mysql....
Hi there guys! I have used a date-field and a time-field in a mysql-database. How should I update these fields through php? This is my code now (it works fine locally with data on a win-machine, but not on Linux at my webhotel - Time doesn't work at all) function safeQuote($value) { // Stripslashes if (get_magic_quotes_gpc()) { $value = stripslashes($value); } // Quote if not integer if (!is_numeric($value)) { $value = ' . mysql_real_escape_string($value) . '; } return $value; } $sql = UPDATE tbforum SET; $sql .= question= . safeQuote($frmQuestion); $sql .= , insertDate=' . $dat . '; $sql .= , insertTime=' . time() . '; $sql .= WHERE IDForum= . safeQuote($idForum); $querys = mysql_query($sql); /G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HOW update time and date-fields to mysql....
On 28/02/06, Gustav Wiberg [EMAIL PROTECTED] wrote: Hi there guys! I have used a date-field and a time-field in a mysql-database. How should I update these fields through php? This is my code now (it works fine locally with data on a win-machine, but not on Linux at my webhotel - Time doesn't work at all) Doesn't work on Linux in what way? Have you tried printing out $sql? Does it contain what you expected? Does the mysql_query() succeed? what does mysql_error() tell you about what went wrong? I'd be absolutely amazed if time() really doesn't work. I'm *guessing* that as you're running stripslashes() on these variables, you're running your local machine with register_globals set on, but the Linux machine has register_globals turned off. -robin
Re: [PHP] HOW update time and date-fields to mysql....
On 2/28/06, Gustav Wiberg [EMAIL PROTECTED] wrote: Hi there guys! I have used a date-field and a time-field in a mysql-database. $sql = UPDATE tbforum SET; $sql .= question= . safeQuote($frmQuestion); $sql .= , insertDate=' . $dat . '; $sql .= , insertTime=' . time() . '; $sql .= WHERE IDForum= . safeQuote($idForum); $querys = mysql_query($sql); Use NOW() for both your date and time fields if the fields have been set up as that. MySQL will then add the date and time according to whatever those values are on your db machine. Cheers Matt