3raser Posted March 14, 2012 Share Posted March 14, 2012 Should this be the proper way of adding the getUsername() text in the query below: mysql_query("UPDATE posts SET content = '$content', lastedit = ". getUsername() .":NOW() WHERE id = '$pid'") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/258876-proper-way/ Share on other sites More sharing options...
MasterACE14 Posted March 14, 2012 Share Posted March 14, 2012 wouldn't really say there's a 'proper' way. More a matter of preference. What you have there is fine. Link to comment https://forums.phpfreaks.com/topic/258876-proper-way/#findComment-1327090 Share on other sites More sharing options...
PFMaBiSmAd Posted March 14, 2012 Share Posted March 14, 2012 Assuming you WANT to combine the string that your php function getUsername() returns with a ':' and the string that the mysql function NOW() returns, you would need to use - $query = "UPDATE posts SET content = '$content', lastedit = CONCAT('". getUsername() .":',NOW()) WHERE id = '$pid'"; You should also form your query statements in a php string variable (makes troubleshooting and error reporting easier.) Echo the $query variable so that you can see what portion of it php contributed and what the resulting sql syntax is. Link to comment https://forums.phpfreaks.com/topic/258876-proper-way/#findComment-1327092 Share on other sites More sharing options...
3raser Posted March 14, 2012 Author Share Posted March 14, 2012 Assuming you WANT to combine the string that your php function getUsername() returns with a ':' and the string that the mysql function NOW() returns, you would need to use - $query = "UPDATE posts SET content = '$content', lastedit = CONCAT('". getUsername() .":',NOW()) WHERE id = '$pid'"; Thank you. I really appreciate the fast response time. Link to comment https://forums.phpfreaks.com/topic/258876-proper-way/#findComment-1327094 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.