'; echo '
✅ PDO and PDO_MySQL extensions are loaded
'; } else { echo '❌ PDO or PDO_MySQL extension is missing
'; echo 'Contact your hosting provider to enable PDO_MySQL extension.
'; exit; } // Test 2: Database Connection echo '✅ Successfully connected to MySQL server
'; } catch (PDOException $e) { echo '❌ Failed to connect to MySQL server
'; echo 'Error: ' . htmlspecialchars($e->getMessage()) . '
'; echo '✅ Successfully accessed database: ' . $dbname . '
'; } catch (PDOException $e) { echo '⚠️ Database does not exist or no access: ' . $dbname . '
'; echo 'Error: ' . htmlspecialchars($e->getMessage()) . '
'; // Try to create the database echo '✅ Database created successfully!
'; } catch (PDOException $e2) { echo '❌ Failed to create database
'; echo 'Error: ' . htmlspecialchars($e2->getMessage()) . '
'; echo 'Please create the database manually in your hosting control panel.
'; exit; } } // Test 4: Check Tables echo '⚠️ No tables found. This is normal for initial setup.
'; echo 'Tables will be created when you run setup.php
'; } else { echo '✅ Found ' . count($tables) . ' tables:
'; echo '❌ Error checking tables: ' . htmlspecialchars($e->getMessage()) . '
'; } // Test 5: Test Write Permissions echo '✅ Database write permissions are working
'; } catch (PDOException $e) { echo '❌ Database write permissions failed
'; echo 'Error: ' . htmlspecialchars($e->getMessage()) . '
'; echo 'Your database user needs CREATE, INSERT, and DROP permissions.
'; } // Configuration Summary echo '| Setting | '; echo 'Value | '; echo '
|---|---|
| ' . htmlspecialchars($key) . ' | '; echo '' . htmlspecialchars($value) . ' | '; echo '
'; echo 'Success! Your database connection is working properly. '; echo 'You can now proceed to run setup.php to create your admin account.'; echo '
'; echo ''; echo 'Security Note: Please delete this test_connection.php file after setup is complete.'; echo '
'; echo ''; ?>