Hacking Prevention - PHP

I have had my sites hacked thrice in the past 10 Months and I am really feeling helpless. I use PHP / MySQL to develop but I do not know how to protect my shared server hosting that it so easy for just about anybody to hack my websites. What do I need to know to safe guard my websites / hosting server.