-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfull_install.php
More file actions
54 lines (44 loc) · 1.63 KB
/
full_install.php
File metadata and controls
54 lines (44 loc) · 1.63 KB
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
// Set the content type to HTML and disable output buffering for real-time feedback
header('Content-Type: text/html; charset=utf-8');
ob_implicit_flush(true);
ob_end_flush();
echo "<!DOCTYPE html><html lang='en'><head><title>Database Installer</title><style>
body { font-family: monospace; background-color: #111; color: #eee; padding: 20px; }
h1 { color: #4caf50; }
h3 { color: #03a9f4; margin: 5px 0; }
.error { color: #f44336; }
</style></head><body>";
echo "<h1>Starting Full Database Installation...</h1>";
// Include the database connection file
include 'db.php';
// Read the SQL file content
$sql_file = 'student.sql';
if (!file_exists($sql_file)) {
die("<p class='error'>Error: SQL file '{$sql_file}' not found.</p></body></html>");
}
$sql_content = file_get_contents($sql_file);
// Split the content into individual queries
$queries = explode(';', $sql_content);
// Loop through each query and execute it
foreach ($queries as $query) {
// Trim whitespace from the query
$trimmed_query = trim($query);
// Ignore empty queries or comment lines
if (empty($trimmed_query) || strpos($trimmed_query, '--') === 0) {
continue;
}
// Execute the query
if ($conn->query($trimmed_query)) {
echo "<h3>✅ Query Executed Successfully</h3>";
} else {
// If an error occurs, print it but continue
echo "<p class='error'>Error executing query: " . $conn->error . "</p>";
echo "<pre class='error'>Query: " . htmlspecialchars($trimmed_query) . "</pre>";
}
}
echo "<h1>🎉 Full Database Installation Complete!</h1>";
echo "</body></html>";
// Close the connection
$conn->close();
?>