SQL injection

I believe this might be a potential source for SQL injection. So let's sanitize $id before storing it in the database.