mrjoeblack;10996656 wrote:Can you elaborate or explain this better, to see if my brain get's it.
As the function name suggests, [man]mysql_real_escape_string/man is only good for sanitizing string data - using it on numerical data (integers, floats, etc.) would be inappropriate.
Instead, you should either verify that the numerical data is actually numerical (e.g. if you expect $_GET['id'] to be an integer ID value, make sure it only contains numbers and not something like "123 OR 1 == 1") or simply "cast" the string data to the appropriate numerical type. See [man]types.type-juggling[/man] for more information on type casting and the like. PHP also has other validation functions for numerical data, such as [man]is_numeric/man, [man]ctype_digit/man, etc.
Looking at it from the SQL side, note that if a column is one of the numerical types, its values should not be enclosed with quotes; '3' is a string containing the ASCII character '3', and 3 is the number that comes after two.
So, if you've got data that you expect to be numerical, don't surround it with quotes and do sanitize/validate it as a numerical value.
mrjoeblack;10996656 wrote:I'm not clear what part you are replacing, can you explain this better for an idiot like me.
Any function that begins with "mysql_" is from the [man]mysql[/man] extension, an extension which is outdated and no longer being actively developed. In other words, the PHP developers have abandoned it and recommend that everyone else does too.
It has been superseded some time ago by the [man]MySQLi[/man] extension (or perhaps even [man]PDO[/man] if you're looking for a more abstract interface).
I know it's full of a lot of information, but consider taking a look at the Overview of the MySQL PHP drivers section of the PHP manual (especially the 'Choosing an API' section: [man]mysqlinfo.api.choosing[/man]).