Table creation
This commit is contained in:
parent
98fff1b107
commit
0650a6df99
@ -4,11 +4,16 @@ $config = parse_ini_file('config.ini');
|
|||||||
|
|
||||||
$conn = mysqli_connect($config['db_host'], $config['db_user'], $config['db_password'], 'blomzt');
|
$conn = mysqli_connect($config['db_host'], $config['db_user'], $config['db_password'], 'blomzt');
|
||||||
|
|
||||||
if ($conn->connect_error) {
|
if (mysqli_connect_errno()) {
|
||||||
die("Connection failed: " . $conn->connect_error);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@ -22,3 +27,14 @@ if ($conn->connect_error) {
|
|||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// Functions
|
||||||
|
|
||||||
|
function TableExists($table, $conn) {
|
||||||
|
$res = mysqli_query($conn, 'SHOW TABLES LIKE \'$table\'');
|
||||||
|
return mysqli_num_rows($res) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in New Issue
Block a user