Any field that a user fills on a form that you process to a database CAN include vicious piece of code.
To avoid this, you have to check data before inserting (or updating) your tables.
Say you have a field "Address" (usually long), set as a "varchar" (100): that 100 characters can be a command!
Worse: fields defined as "TEXT".
- Before inserting/updating, check these string queries for malicious code, commands etc (words like "insert", "delete", "select", "create", file extensions such as "asm","exe"), or non-texts (ie characters below 0x1F) and reject if you find one.
However, don't be too paranoid: if your site is decent, so will be your visitors.
Just make an automatic DB backup daily.