Writing safely to a database / files located on a webserver (bluehost)

Hello everyone,

I need to write/read to/from a database or textfiles on a webspace. In the past I read on the forums that this is very unreliable because files / databases get easily corrupted.

Is there any way I can safely write / read to a remote database on a webserver.

Before any transaction (write / read) I intend to check the internet availability. Also the database / files will be closed as soon a transaction (read/write) ended and opened again just before any new write/read.

I am thinking first writing all the data to local files and then just write to the remote server. When an error occur, then I can restore the remote database/files with the saved local data.

I will appreciate any advice / suggestions very much. I thank you in advance for your efforts to help me.

Wish you all a very nice day.


P.S. : on this moment I have difficulty connecting to the internet, therefore it can take a day or few days to respond. Anyway, I will respond to all replies. Please, accept my apology for this. Thank you very much for your understanding and patience.