I don’t use mysqli_ statements, I use PDO --> So I went to php.net http://php.net/manual/en/mysqli-result.fetch-assoc.php and modify some code. This is what I would do. 
[php]<?php
$mysqli = new mysqli(“localhost”, “my_user”, “my_password”, “gps”);
/* check connection */
if ($mysqli->connect_errno) {
printf(“Connect failed: %s\n”, $mysqli->connect_error);
exit();
}
$query = "SELECT
devices.positionId,
positions.id,
devices.name
as unit,
devices.status
as status,
devices.lastUpdate,
positions.latitude,
positions.longitude,
positions.speed,
FROM devices, positions
WHERE
positions.id = devices.id AND
devices.status
= “online”
";
/* Me thinks this is where you were getting the error */
if ($result = $mysqli->query($query)) {
/* fetch associative array */
while ($row = $result->fetch_assoc()) {
echo "id: " . $row["unit"]. " - Name: " . $row["latitude"]. " " . $row["longitude"]. "<br>";
}
/* free result set */
$result->free();
}
/* close connection */
$mysqli->close();[/php]