-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.php
54 lines (42 loc) · 1.15 KB
/
install.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
<?php
// Database connection parameters
$servername = "";
$username = "";
$password = "";
$database = "dishacet";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Create the database if it doesn't exist
$sqlCreateDb = "CREATE DATABASE IF NOT EXISTS $database";
if ($conn->query($sqlCreateDb) === TRUE) {
echo "Database created successfully or already exists.<br>";
} else {
echo "Error creating database: " . $conn->error;
$conn->close();
exit();
}
// Close the initial connection
$conn->close();
// Connect to the newly created database
$conn = new mysqli($servername, $username, $password, $database);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// SQL file path
$sqlFile = "dishacet.sql";
// Read the SQL file
$sql = file_get_contents($sqlFile);
// Execute the SQL commands
if ($conn->multi_query($sql)) {
echo "SQL file executed successfully.";
} else {
echo "Error executing SQL file: " . $conn->error;
}
// Close connection
$conn->close();
?>