Page 1 of 1

Help - Inserting to a timestamp

Posted: Thu Sep 18, 2003 11:06 am
by Linkjames
Ok, as best I can tell, the following code should insert the variables into the table, which it does do, and it should set the date in a timestamp feild, which it dosen't. Bugger. The timestamp feild would be the last of the 5 INSERT intos btw. I hope that makes sense

Code: Select all

if (mysql_num_rows($result) == 0) { 
echo 'Sorry, your question is not in our database<P>';
echo '<a href="search.php">Perform another search</a>';
$no = No;
$notasked=mysql_query("INSERT INTO ansr_info VALUES ('','$search','','$no','')");
}

Posted: Thu Sep 18, 2003 11:15 am
by Linkjames
Always the way. You finally give in and accept you can't do it and post on the forums, and seconds later you get the answer. Just FYI, it worked with the following code...

Code: Select all

if (mysql_num_rows($result) == 0) { 
echo 'Sorry, your question is not in our database<P>';
echo '<a href="search.php">Perform another search</a>';
$no = No;
$notasked=mysql_query("INSERT INTO ansr_info (question, answer, answered) VALUES ('$search','','$no')");
}

Posted: Thu Sep 18, 2003 1:21 pm
by JAM
If you are to insert the current time/date/timestamp into sql, you can use NOW().

Code: Select all

"insert into table (something,mydatefield) values('foo',NOW()+0)"
Edited: Changed NOW() to NOW()+0 as below...

Posted: Thu Sep 18, 2003 2:07 pm
by Linkjames
I tryed using NOW() and it didn't work. I mut have missed somthing.
Thanks for the input though.

Posted: Thu Sep 18, 2003 2:57 pm
by JAM
Oh, sorry, my bad...
NOW()+0 might be a better suggestion.