Misc-small-projects/blomzt/main.php

40 lines
718 B
PHP
Raw Normal View History

<?php
2016-05-14 23:35:09 +02:00
$config = parse_ini_file('config.ini');
$conn = mysqli_connect($config['db_host'], $config['db_user'], $config['db_password'], 'blomzt');
2016-05-15 01:35:08 +02:00
if (mysqli_connect_errno()) {
die("Connection failed: " . mysqli_connect_error());
2016-05-14 23:35:09 +02:00
}
2016-05-15 01:35:08 +02:00
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);
}
?>
<html>
<head>
2016-05-14 23:35:09 +02:00
<title>Blomzt</title>
</head>
<body>
2016-05-15 01:35:08 +02:00
</body>
2016-05-15 01:35:08 +02:00
</html>
<?php
// Functions
function TableExists($table, $conn) {
$res = mysqli_query($conn, 'SHOW TABLES LIKE \'$table\'');
return mysqli_num_rows($res) > 0;
}
?>