gpstools/setup.php

22 lines
811 B
PHP
Raw Normal View History

2016-01-15 07:11:36 +00:00
<?php
require_once("config.php");
2016-01-15 07:11:36 +00:00
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
2017-10-05 12:43:11 +00:00
$sql = "CREATE TABLE IF NOT EXISTS tracker ( ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP, device VARCHAR(38), lat DOUBLE, lon DOUBLE, PRIMARY KEY(ts, device) );";
$sql2 = "CREATE TABLE IF NOT EXISTS users ( user VARCHAR(64) PRIMARY KEY, password VARCHAR(128), admin BOOLEAN );";
$sql3 = "CREATE TABLE IF NOT EXISTS device ( device VARCHAR(38) PRIMARY KEY, passkey VARCHAR(128) );";
2016-01-15 07:11:36 +00:00
2017-10-05 12:43:11 +00:00
if (!mysqli_query($conn, $sql)) die('Error: ' . mysqli_error($conn));
if (!mysqli_query($conn, $sql2)) die('Error: ' . mysqli_error($conn));
if (!mysqli_query($conn, $sql3)) die('Error: ' . mysqli_error($conn));
2016-01-15 07:11:36 +00:00
mysqli_close($conn);
echo "OK";