I can't add data to my sql database using a php file

Using non-browser tools to interact with your site is not allowed:

Do the files show up in the database? Did you try turning on error message?

Great! Note that localhost is a development platform, and settings and such are going to be different. Also, localhost is missing quite a bit of security features that production servers have. Just because your code works there does not mean it will work anywhere else.