Testing for a SQL injection
Posted: Thu Sep 09, 2010 1:38 pm
I’m just learning and testing for security in some scripts and I was wondering if the following script has a weakness.
If somebody tries to inject an SQL query will (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']); catch it or is it missing it being tested for an integer value too?
Code: Select all
if (isset($_GET['id'])) {
$colname_GetLetter = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($****, $*****);
$query_GetLetter = sprintf("SELECT * FROM letters WHERE id = %s ", $colname_GetLetter);