From 0650a6df9908e7c0a719e57402ee89e33461e58e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20L=C3=B8vbr=C3=B8tte=20Olsen?= Date: Sun, 15 May 2016 01:35:08 +0200 Subject: [PATCH] Table creation --- blomzt/main.php | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/blomzt/main.php b/blomzt/main.php index 159398d..f31d2f6 100644 --- a/blomzt/main.php +++ b/blomzt/main.php @@ -4,11 +4,16 @@ $config = parse_ini_file('config.ini'); $conn = mysqli_connect($config['db_host'], $config['db_user'], $config['db_password'], 'blomzt'); -if ($conn->connect_error) { - die("Connection failed: " . $conn->connect_error); +if (mysqli_connect_errno()) { + die("Connection failed: " . mysqli_connect_error()); } - +if (!TableExists($config['db_table'], $conn)) { + $sql = 'CREATE TABLE ' . $config['db_table'] . ' ( + id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, location Point NOT NULL, url VARCHAR(65), date_added TIMESTAMP) + '; + mysqli_query($conn, $sql); +} ?> @@ -19,6 +24,17 @@ if ($conn->connect_error) { Blomzt - + - \ No newline at end of file + + + + 0; +} + +?> \ No newline at end of file