Help - Inserting to a timestamp

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Linkjames
Forum Commoner
Posts: 90
Joined: Tue Sep 16, 2003 8:39 am

Help - Inserting to a timestamp

Post 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','')");
}
Linkjames
Forum Commoner
Posts: 90
Joined: Tue Sep 16, 2003 8:39 am

Post 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')");
}
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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...
Last edited by JAM on Thu Sep 18, 2003 2:58 pm, edited 1 time in total.
Linkjames
Forum Commoner
Posts: 90
Joined: Tue Sep 16, 2003 8:39 am

Post by Linkjames »

I tryed using NOW() and it didn't work. I mut have missed somthing.
Thanks for the input though.
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Oh, sorry, my bad...
NOW()+0 might be a better suggestion.
Post Reply