I have a database named user_job_apply(id, job_id, postby_id, applier_id, flag, flag_wall, time_apply).
The "time_apply" type in my database was set to :datetime
My problem is that the following piece of code inserts everything suceesfully in my databe, but it does not insert the value for $timeString. When I look in my database it shows 0000-00-00 00:00:00. Any idea what is the problem here?
I have tested by echoing $timeString and it displays date and time with success, but i cannot pass it into my database. Any idea how to fix this?
<?php
// the next two values comes from a form
$the_job_code = mysql_real_escape_string($_POST['jobid']);
$the_postedby = mysql_real_escape_string($_POST['postedby']);
// use it to get current time from user's computer
$timeString= '
<script language="javascript">
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10) {
dd="0"+dd
}
if(mm<10) {
mm="0"+mm
}
today = mm+"/"+dd+"/"+yyyy + " " +today.getHours() + ":" + today.getMinutes()+":" + today.getSeconds();
document.write(today);
</script> ';
mysql_query("INSERT INTO `user_job_apply` VALUES ('', '$the_job_code', '$the_postedby ', '$session_user_id', '1', '1', '$timeString') ");
?>