Even if you protected your variables from being injected with a parameterized query or mysql_real_escape_string()(not mysql_escape_string()), you should still check them on the server side to make sure they match the expected input type. Thus, if they do not, you can return an error message to your user with a request to repeat these form fields.
If you use a parameterized query, such as that proposed by MySQLi as prepared statements, you also do not need to avoid strings. However, if you are not using a parameterized query, you must call mysql_real_escape_string()for each input parameter received by PHP.
source
share