missing a closing * } * (2) if(s), (1) foreach(), you only have (2) * } * put another one after the (2) you already have! Also please validate your inputs, you will have many undefined errors if you don't!

Also don't trust addslashes() for db inserts, always use mysql_real_escape_string()

I think you you like being argumentative, I do to, hehe, addslashes does not protect against all unicode character sets, so sql injection is possible which can allow sub queries to be easily crafted and executed. I was going to write a long winded answer with some examples, but script kiddies are always around, so I will just point you to a simple article that explains (1) of the many methods that are available if you know MySQL and unicodes dirty little secrets.