# 🔧 Web Installer Troubleshooting

## ❌ Error: "Access denied for user ''@'localhost' (using password: NO)"

This error means the form data isn't being submitted correctly.

### **Solution:**

**Re-upload the fixed `install/index.php` file** - I just fixed this issue!

The problem was:
- Form values weren't being preserved
- Password field was required but could be empty
- No validation before database connection

**What I fixed:**
- ✅ Added form value preservation on error
- ✅ Made password optional (for databases without passwords)
- ✅ Added validation before connection attempt
- ✅ Added debug info showing what credentials were used
- ✅ Added explicit form action URL

---

## 📋 Common Database Errors

### **1. "Access denied for user 'username'@'localhost'"**

**Cause:** Wrong username or password

**Solution:**
- Double-check your MySQL username from cPanel
- Verify password is correct
- Make sure you're using the database user, not cPanel user

---

### **2. "Unknown database 'dbname'"**

**Cause:** Database doesn't exist

**Solution:**
1. Go to cPanel → MySQL Databases
2. Create the database first
3. Note the full database name (usually: `cpaneluser_dbname`)
4. Use the FULL name in the installer

---

### **3. "Host 'xxx.xxx.xxx.xxx' is not allowed to connect"**

**Cause:** Database user doesn't have remote access

**Solution:**
1. Go to cPanel → MySQL Databases
2. Find "Remote MySQL"
3. Add your IP or use `%` for any host (not recommended for production)
4. Or use `localhost` as host

---

### **4. Form values disappear after error**

**Cause:** Old version of installer

**Solution:**
- Re-upload the fixed `install/index.php` file
- Clear browser cache
- Try again

---

## ✅ How to Get Correct Database Credentials

### **In Namecheap cPanel:**

1. **Go to:** MySQL Databases
2. **Look for:**
   - **Database Name:** Usually `cpaneluser_dbname`
   - **Database User:** Usually `cpaneluser_username`
3. **Create user if needed:**
   - Click "Add New User"
   - Set username and password
   - Click "Create User"
4. **Add user to database:**
   - Under "Add User To Database"
   - Select user and database
   - Click "Add"
   - Grant ALL PRIVILEGES
   - Click "Make Changes"

---

## 🔍 Debug Mode

If you're still having issues, you can enable debug mode:

**Edit `install/index.php` line 9:**

```php
// Add this after session_start();
error_reporting(E_ALL);
ini_set('display_errors', 1);
```

This will show detailed PHP errors.

---

## 🆘 Still Not Working?

### **Option 1: Use Command-Line Installer**

If the web installer keeps failing:

1. SSH into your server
2. Run: `./install.sh`
3. Follow the prompts

### **Option 2: Manual Installation**

1. Copy `.env.example` to `.env`
2. Edit `.env` with your credentials
3. Import database manually:
   ```bash
   mysql -u username -p database_name < database/schema.sql
   ```
4. Run: `npm install && npm run build`

---

## 📞 Need Help?

Check these files:
- `INSTALLATION_GUIDE.md` - Full installation guide
- `DEPLOYMENT_STEPS.md` - Step-by-step deployment
- `README.md` - Project overview

---

**Most common fix:** Re-upload the fixed `install/index.php` file!
