╔══════════════════════════════════════════════════════════════════════════════╗ ║ 🔧 DATABASE UPDATE - QUICK FIX ║ ║ Fix "Column not found" Error ║ ╚══════════════════════════════════════════════════════════════════════════════╝ ❌ ERROR YOU'RE SEEING: ═══════════════════════════════════════════════════════════════════════════════ Fatal error: Column not found: 1054 Unknown column 'role' in 'where clause' This happens because your database doesn't have the new 'role' and 'username' columns yet. ═══════════════════════════════════════════════════════════════════════════════ ✅ SOLUTION - AUTOMATIC UPDATE (EASIEST) ═══════════════════════════════════════════════════════════════════════════════ I've created an automatic update script that will fix your database. STEP 1: Open the Update Script ───────────────────────────────────────────────────────────────────────────── Open this URL in your browser: http://localhost/222/fast-earn-limited/update_db.php STEP 2: Wait for Completion ───────────────────────────────────────────────────────────────────────────── The script will automatically: ✓ Add 'username' column to users table ✓ Add 'role' column to users table ✓ Update admin user with username='admin' and role='admin' ✓ Set all existing users to role='user' STEP 3: Delete the Update Script (Security) ───────────────────────────────────────────────────────────────────────────── After successful update, DELETE this file: c:\xampp\htdocs\222\fast-earn-limited\update_db.php STEP 4: Test Login ───────────────────────────────────────────────────────────────────────────── Admin Login: http://localhost/222/fast-earn-limited/admin/login.php Username: admin Password: admin123 ═══════════════════════════════════════════════════════════════════════════════ 🔄 ALTERNATIVE - MANUAL UPDATE (If automatic fails) ═══════════════════════════════════════════════════════════════════════════════ OPTION 1: Re-import Database (Recommended if no important data) ───────────────────────────────────────────────────────────────────────────── 1. Open phpMyAdmin: http://localhost/phpmyadmin 2. Click on database: fast_earn_2 3. Click "Drop" to delete the database 4. Click "New" to create database: fast_earn_2 5. Click "Import" tab 6. Choose file: database.sql 7. Click "Go" ⚠️ WARNING: This will delete ALL existing data! OPTION 2: Run SQL Commands Manually ───────────────────────────────────────────────────────────────────────────── 1. Open phpMyAdmin: http://localhost/phpmyadmin 2. Select database: fast_earn_2 3. Click "SQL" tab 4. Copy and paste this SQL: -- Add missing columns ALTER TABLE users ADD COLUMN username VARCHAR(50) UNIQUE DEFAULT NULL COMMENT 'Username for admin login' AFTER id; ALTER TABLE users ADD COLUMN role ENUM('user', 'admin') DEFAULT 'user' COMMENT 'User role' AFTER password; -- Update admin user UPDATE users SET username = 'admin', role = 'admin', full_name = 'Administrator' WHERE id = 1; -- Set all other users to role 'user' UPDATE users SET role = 'user' WHERE id != 1; 5. Click "Go" ═══════════════════════════════════════════════════════════════════════════════ ✅ AFTER UPDATE - WHAT CHANGES ═══════════════════════════════════════════════════════════════════════════════ Your users table will now have: ✓ username column (only admin has username='admin') ✓ role column (admin has role='admin', users have role='user') Admin Login: URL: http://localhost/222/fast-earn-limited/admin/login.php Username: admin (or email or phone) Password: admin123 User Login: URL: http://localhost/222/fast-earn-limited/login.php Email/Phone: (your credentials) Password: (your password) ═══════════════════════════════════════════════════════════════════════════════ 🔍 VERIFY UPDATE WAS SUCCESSFUL ═══════════════════════════════════════════════════════════════════════════════ 1. Open phpMyAdmin 2. Select database: fast_earn_2 3. Click on table: users 4. Click "Structure" tab 5. You should see these columns: - id - username (NEW) - full_name - email - phone - account_type - account_number - account_name - password - role (NEW) - profile_photo - wallet_balance - ... (other columns) ═══════════════════════════════════════════════════════════════════════════════ 📋 QUICK CHECKLIST ═══════════════════════════════════════════════════════════════════════════════ □ Opened update_db.php in browser □ Saw "Database Update Complete" message □ Deleted update_db.php file □ Can access admin login page □ Can login as admin with username "admin" □ Can login as user with email/phone □ No more "column not found" errors ═══════════════════════════════════════════════════════════════════════════════ 🎯 SUMMARY ═══════════════════════════════════════════════════════════════════════════════ The easiest way to fix this: 1. Open: http://localhost/222/fast-earn-limited/update_db.php 2. Wait for success message 3. Delete update_db.php 4. Login at: http://localhost/222/fast-earn-limited/admin/login.php 5. Username: admin | Password: admin123 Done! ✅ ═══════════════════════════════════════════════════════════════════════════════