Hi and thanks for your reply.
The code below may not be the best looking code ever written but from a functionality point it works. In you opinion is the code safe against SQL injection.
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_pin_results = "-1";
if (isset($_POST['pin'])) {
$colname_pin_results = (int)(get_magic_quotes_gpc()) ? $_POST['pin'] : addslashes($_POST['pin']);
}
$colname1_pin_results = "-1";
if (isset($_POST['pin'])) {
$colname1_pin_results = (int)(get_magic_quotes_gpc()) ? $_POST['pin'] : addslashes($_POST['pin']);
}
$colname2_pin_results = "-1";
if (isset($_POST['pin'])) {
$colname2_pin_results = (int)(get_magic_quotes_gpc()) ? $_POST['pin'] : addslashes($_POST['pin']);
}
$colname3_pin_results = "-1";
if (isset($_POST['pin'])) {
$colname3_pin_results =(int) (get_magic_quotes_gpc()) ? $_POST['pin'] : addslashes($_POST['pin']);
}
$colname4_pin_results = "-1";
if (isset($_POST['pin'])) {
$colname4_pin_results = (get_magic_quotes_gpc()) ? $_POST['pin'] : addslashes($_POST['pin']);
}
$colname5_pin_results = "-1";
if (isset($_POST['pin'])) {
$colname5_pin_results =(int) (get_magic_quotes_gpc()) ? $_POST['pin'] : addslashes($_POST['pin']);
}
$colname6_pin_results = "-1";
if (isset($_POST['pin'])) {
$colname6_pin_results = (int)(get_magic_quotes_gpc()) ? $_POST['pin'] : addslashes($_POST['pin']);
}
$colname7_pin_results = "-1";
if (isset($_POST['pin'])) {
$colname7_pin_results = (int)(get_magic_quotes_gpc()) ? $_POST['pin'] : addslashes($_POST['pin']);
}
$colname8_pin_results = "-1";
if (isset($_POST['pin'])) {
$colname8_pin_results =(int) (get_magic_quotes_gpc()) ? $_POST['pin'] : addslashes($_POST['pin']);
}
$colname9_pin_results = "-1";
if (isset($_POST['pin'])) {
$colname9_pin_results = (int)(get_magic_quotes_gpc()) ? $_POST['pin'] : addslashes($_POST['pin']);
}
$colname10_pin_results = "-1";
if (isset($_POST['pin'])) {
$colname10_pin_results =(int) (get_magic_quotes_gpc()) ? $_POST['pin'] : addslashes($_POST['pin']);
}
mysql_select_db($database_pin, $pin);
$query_pin_results = sprintf("SELECT * FROM members WHERE member_id = %s OR secure_id_1 = %s OR secure_id_2 = %s OR secure_id_3 = %s OR secure_id_4 = %s OR secure_id_5 = %s OR secure_id_6 = %s OR secure_id_7 = %s OR secure_id_8= %s OR secure_id_9 = %s OR secure_id_10 = %s ", GetSQLValueString($colname_pin_results, "int"),GetSQLValueString($colname1_pin_results, "int"),GetSQLValueString($colname2_pin_results, "int"),GetSQLValueString($colname3_pin_results, "int"),GetSQLValueString($colname4_pin_results, "int"),GetSQLValueString($colname5_pin_results, "int"),GetSQLValueString($colname6_pin_results, "int"),GetSQLValueString($colname7_pin_results, "int"),GetSQLValueString($colname8_pin_results, "int"),GetSQLValueString($colname9_pin_results, "int"),GetSQLValueString($colname10_pin_results, "int"));
$pin_results = mysql_query($query_pin_results, $pin) or die(mysql_error());
$row_pin_results = mysql_fetch_assoc($pin_results);
$totalRows_pin_results = mysql_num_rows($pin_results);