codeboy89 Posted October 29, 2009 Share Posted October 29, 2009 I am using time() in the snippet below, I would like to use CURDATE() and have the database setup for date. My problem is, I am not sure how to change the PHP coding, I keep getting errors just adding CURDATE() where time() is. Any help would be greatly appreciated... $update = mysql_query("UPDATE comments SET comment='".$comment."',created_at='".time()."' WHERE user_id=".$_SESSION['logged_id']); } else { $insert = mysql_query("INSERT INTO comments(`id`,`user_id`,`comment`,`created_at`) VALUES(0,".$_SESSION['logged_id'].",'".$comment."','".time()."')"); Link to comment https://forums.phpfreaks.com/topic/179468-change-snippet-to-use-curdate/ Share on other sites More sharing options...
Mchl Posted October 29, 2009 Share Posted October 29, 2009 CURDATE() is MySQL's function, while time() is PHP's, so you have to put it inside double quotes, not outside. $update = mysql_query("UPDATE comments SET comment='".$comment."',created_at=CURDATE() WHERE user_id=".$_SESSION['logged_id']); } else { $insert = mysql_query("INSERT INTO comments(`id`,`user_id`,`comment`,`created_at`) VALUES(0,".$_SESSION['logged_id'].",'".$comment."',CURDATE())"); Link to comment https://forums.phpfreaks.com/topic/179468-change-snippet-to-use-curdate/#findComment-946894 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.