You are correct to validate your data. However without knowing what the purpose of the data is, it's impossible to advise on how to validate it. Validation & input security is about applying principles properly rather than any one specific set of code that fixes all potential issues. If it was that easy then SQL injection would not be top of the OWASP top 10.
What you must do is always ensure the data matches what you expect. For example a text string in a numeric field could cause your code to do unexpected things. PHP has many functions that can be used for validation. is_numeric, strlen and preg_match - regular expressions are great for validating dates, zip codes and a host of other input.
I'm not sure why you are using stripslashes, esp. when talking about database queries. It was once common to see addslashes in use, so much so that PHP had magicquotes to automatically addslashes on all input. It's worth reading those pages of the manual as they cover the issues of blanket changing all input very well.
The 2nd thing to do is decide how you want to handle input that does not match expectations. It may be worth logging the errors so you can resolve any issues with your front end code. Are you going to let the user know that there was a problem with the input?
Final thought on your question, you are asking about validating the input, but stripslashes and htmlspecialchars both modify the input as well. This can create issues later on, for example if you happen to want slashes in your input data for some use cases or the input is an image and not text.
Have different validation for different input types. Keep the encoding/escaping code to use when required. E.g. mysqli->real_escape_string before db inserts and htmlspecialchars before using the data in xhtml output.
Read around the issue, learn the OWASP top 10, ask on S.O. if you are struggling on a particular input scenario. Apply the lessons and the monitor your application in the real world. Don't just assume it will be secure and you will go a long way to avoiding the pain & embarrassment of fixing a hacked system.
mysql_functions anymore. Usemysqlifunctions orPDOfunctions. Then use parameterized queries.