GPS to webserver

Hey guys,

I have an LtAP device and having issues sending the longitude readings to a webserver, I can send the Latitude readings.
If I use
/tool fetch http-method=post http-header-field=“Content-Type:application/json” http-data=“{"lat":"$lat","lon":"25.12"}”
url=“http://webserverIP/index.php” in the terminal the longitude will submit the 25.12 as the longitude reading into the database but if I use the real reading say -7.123456
no data will enter the database, has anyone encountered this issue?



script for coords collection

{
:global lat
:global lon
/system gps monitor once do={
:set $lat $(“latitude”)
:set $lon $(“longitude”)
}
:put (“{"lat":"” . $lat . “","lon":"” . $lon . “"}”)

/tool fetch http-method=post http-header-field=“Content-Type:application/json” http-data=“{"lat":"$lat","lon":"$lon"}”
url=“http://webserverIP/index.php
}




PHP code running at the head of the index.php file

<?php // make sure this directory exists and is writeable. file will be created automatically upon first fetch $loc = dirname(__FILE__).'/sqlite_db/coord.db'; $db = new SQLite3($loc,SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE); $raw = file_get_contents('php://input'); $raw = preg_replace('/\\x00/','',$raw); $data = json_decode($raw); \ \ \ if (!empty($data) && is_object($data) && property_exists($data,'lat') && property_exists($data,'lon')){ if(file_exists($loc)) echo 'exists!'.chr(0xa); $src = 'SELECT name FROM sqlite_master WHERE type=\'table\' AND name=\'coordinates\''; $res = $db->querySingle($src); if (count($res)==0){ $db->exec('CREATE TABLE coordinates (latitude TEXT, longitude TEXT, time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, added TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) '); } $regex = '/^(|\-)([0-9]{2,3}\.[0-9]{0,8})$/'; if (preg_match($regex,$data->lat) && preg_match($regex,$data->lon) ) { $lat = $data->lat; $lon = $data->lon; } $ins = 'INSERT INTO coordinates (latitude,longitude) VALUES (\''.SQLite3::escapeString($lat).'\',\''.SQLite3::escapeString($lon).'\')'; $db->exec($ins); die(); } ?>