A pragmatic approach is to do proper input validation and in www case - proper output escaping.
For each variable You get as input, apply the most strict filtering rules that make sense:
If You get an id of a page, then an is_integer(myvariable) && myvariable >0 ; is a proper check.
Security process is a risk management process that goes along these lines:
1) Examine the use-case;
2) Think of all risks that apply;
3) Choose which risks to eliminate (by secure coding or other means), which risks to mitigate by compensating controls (e.g. a threat to sue or user policy) and which risks to accept (because they are so remote or too expensive to counter). Don't forget to monitor those risks though.
So, juxtaposing the two paragraphs above, we come to the conclusion that a programmer writing a request handler for web should always be aware of possible risks and take the decision to eliminate/mitigate/accept them. As the programmer has limited time on his hands, he should apply fascist input validation and don't rely on the data source to have sanitized data, as he might not be the only one using same database.
On a side note, if You just think of OWASP Top Ten, you have done your due diligence.