-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset.php
17 lines (15 loc) · 854 Bytes
/
set.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
$options ['host'] = "xxxxxxxxxxxxx";
$options ['database'] = 'xxxxxxxxxxxxx';
$options ['user'] = 'xxxxxxxxxxxxx';
$options ['password'] = 'xxxxxxxxxxxxx';
$db = mysql_connect($options['host'], $options['user'], $options['password']);
if(!$db) print_r(mysql_error());
mysql_select_db($options['database']);
$data = json_decode($_REQUEST['data']);
$sql = '';
foreach($data as $row) {
$sql = 'INSERT INTO nodes (id, user_name, `lat`, `long`, heading, speed, game_id, location) VALUE ("'.$row->id.'", "'.$row->user_name.'", "'.$row->lat.'", "'.$row->long.'", "'.(is_null($row->heading) ? 0:$row->heading).'", "'.(is_null($row->speed) ? 0:$row->speed).'", '.$row->game_id.',PointFromText("POINT('.$row->lat.' '.$row->long.')"));';
mysql_query($sql);
}
echo json_encode(array('error' => mysql_error(), 'message' => !mysql_error() ? 'OK':'Error'));