This is a part of my code, and it is working fine, but it doesn't fill the $invoice_mail_month variable.
As to the above author: I was working on that one before, but they always need to be billed. But since the don't always use the service, it's not possible. One solution would be add mail_month = 0 in my mysql table for every user, but that would be a waste of space in my table.