How do you output the contents of an array as a comma separated string?
5 answers
Make sure you pass the results through mysql_real_escape_string () before executing your query . This should prevent sql injection if you use implode () as others suggest.
And as nickf mentions, always check to make sure the array is not empty or null first, and handle those cases. Since you are only dealing with int, it doesn't hurt to check the type of your assignments, otherwise you will get sql errors if the string slips somehow.
+2
source to share