This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcreatedb.php
61 lines (53 loc) · 1.77 KB
/
createdb.php
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
<?php
//weather34 weatherstation create the database then create the tables
include('settings1.php');
$servername = $db_host;
$username = $db_user;
$password = $db_pass;
$dbname = "weatherstation";
// Create connection to database access
$conn = new mysqli($servername, $username, $password);
// Check connection to database access
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Create weatherstation database
$sql = "CREATE DATABASE weatherstation";
if ($conn->query($sql) === TRUE) {
echo " weather34 Database weatherstation created successfully";
} else {
echo "weather34 Error creating database: " . $conn->error;
}
$conn->close();
// Create connection to database access
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection to database access
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// weatherstation sql to create table
$sql = "CREATE TABLE `weatherstation` (
`ID` int(11) NOT NULL,
`time` text NOT NULL,
`outsideTemp` decimal(10,1) NOT NULL,
`barometer` decimal(10,2) NOT NULL,
`raintoday` decimal(10,2) NOT NULL,
`UV` decimal(10,0) NOT NULL,
`windgustmph` decimal(10,1) NOT NULL,
`windSpeed` decimal(10,1) NOT NULL,
`radiation` decimal(10,2) NOT NULL,
`dewpoint` decimal(10,2) NOT NULL,
`rainrate` decimal(10,2) NOT NULL,
`direction` decimal(10,2) NOT NULL,
`date` text NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`lightning` decimal(10,0) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
";
if ($conn->query($sql) === TRUE) {
echo "weather34 Table for weatherstation created successfully";
} else {
echo "weather34 Error creating table: " . $conn->error;
}
$conn->close();
?>