"; //test returns query string
//Break query string into parts delimited by the "&" (key=val)
$query_string = explode( '&', $data );
// echo "$query_string
"; //test returns "Array"
$args = array( ); // return array
// echo "$args
" //test returns "Array"
//Loop through the array, break at "=",
foreach( $query_string as $chunk )
{
$chunk = explode( '=', $chunk );
list( $key, $val ) = $chunk;
// echo "$key $val
"; //test returns keys and their associated values
/*
****************************************************
For each iteration of the loop test for key, create a variable and set its value to the one associated with it. These values will be used later on to update the database. If you have any different sensor values than the ones here, you need to create your own test. Format is-
"case ($key == "your_parameter"): //If the key matches returns true
global $your_parameter; //declare parameter as global variable
$your_parameter = $val; //set the value
break;" //Back to the loop
***************************************************
*/
switch ($key):
case ($key == "tm"):
global $tm;
$tm = $val;
break;
case ($key == "t1"):
global $t1;
$t1 = $val;
break;
case ($key == "t2"):
global $tm;
$t2 = $val;
break;
case ($key == "dp"):
global $dp;
$dp = $val;
break;
case ($key == "rh"):
global $rh;
$rh = $val;
break;
case ($key == "bp"):
global $bp;
$bp = $val;
break;
case ($key == "wdspd"):
global $wdspd;
$wdspd = $val;
break;
case ($key == "gst"):
global $gst;
$gst = $val;
break;
case ($key == "wddir"):
global $wddir;
$wddir = $val;
break;
case ($key == "rn"):
global $rn;
$rn = $val;
break;
case ($key == "drn"):
global $drn;
$drn = $val;
break;
case ($key == "rnrt"):
global $rnrt;
$rnrt = $val;
break;
endswitch;
$args[ $key ] = urldecode( $val );
}
// connect to the database
$con = mysql_connect("$host","$user","$pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// select the database
mysql_select_db("$db", $con) or die ("error selecting db");
// Insert values into the fields in the database
mysql_query("INSERT INTO $dbf (tm, t1, t2, dp, rh, bp, wdspd, gst, wddir, rn, drn, rnrt) VALUES ('$tm','$t1','$t2','$dp','$rh','$bp','$wdspd','$gst','$wddir','$rn','$drn','$rnrt')");
mysql_close($con); //close the database
// echo "$tm $t1 $t2 $dp $rh $bp $wdspd $gst $wddir $rn $drn $rnrt"; //test to see if created variables get this far
?>