Hi all.
I am trying to set up a script that will process the content of 2 variables which arrive at the site via a SMS Gateway. If I set 2 two variables with static data the script works fine.
If I set the variables to the $REQUEST statements the data in the $REQUEST's is not written to the database.
I have spoken to the SMS Gateway provides and they say that by using $REQUEST or $POST the script should work, (well they would say that, would'nt they)
Can anyone see where in the script the problem may be.
<?php require_once('../Connections/connect.php'); ?>
<?php
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;
}
}
// If I use the variables below the script work fine.
//$s = 888888;
//$m = 1338014;
// but if I use the variables below the content of the avriables is not written to the database.
$s = $_REQUEST['source'];
$m = $_REQUEST['Body'];
$updateSQL = sprintf("UPDATE members SET mobile=$s WHERE member_id=$m");
mysql_select_db($database_b_domain, $connect);
$Result1 = mysql_query($updateSQL, $connect) or die(mysql_error());
$colname_act = "-1";
if (isset($_GET['member_id'])) {
$colname_act = $_GET['member_id'];
}
mysql_select_db($database_b_domain, $connect);
$query_act = sprintf("SELECT member_id, mobile FROM members WHERE member_id = %s", GetSQLValueString($colname_act, "int"));
$act = mysql_query($query_act, $connect) or die(mysql_error());
$row_act = mysql_fetch_assoc($act);
$totalRows_act = mysql_num_rows($act);
?>