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()); Quote 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. Quote 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. Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/258876-proper-way/#findComment-1327094 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.