-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch.php
More file actions
63 lines (46 loc) · 1.02 KB
/
fetch.php
File metadata and controls
63 lines (46 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
$host = $_GET['argument1'];
$user = $_GET['argument2'];
$pass = $_GET['argument3'];;
$r = mysql_connect($host, $user, $pass);
if (!$r) {
echo "Could not connect to server\n";
trigger_error(mysql_error(), E_USER_ERROR);
} else {
//echo "Connection established\n";
}
$r = mysql_select_db('testst1984');
if( !$r)
{
echo "could not select database";
}
else
{
//echo "database selected";
}
$query = "SELECT id, latitude, longitude, devname from bluetoothmap";
$rs = mysql_query($query);
if (!$rs) {
echo "Could not execute query: $query\n";
trigger_error(mysql_error(), E_USER_ERROR);
} else {
//echo "Query: $query executed\n";
}
echo "{ positions : [ \n";
$numresults = mysql_num_rows($rs);
$counter = 0;
while( $row = mysql_fetch_array($rs) )
{
$s = stripslashes($row[3]);
echo "{ id:$row[0], latitude:$row[1], longitude:$row[2], devname:\"$s\" }";
++$counter;
if( $counter < $numresults )
{
echo ",";
}
echo "\n";
}
echo "] }\n";
mysql_close();
?>
<?php