Overview
This guide covers common problems you may encounter when developing or deploying Pro Stock Tool, along with step-by-step solutions.Database Connection Issues
Error: Connection refused
Error: Connection refused
Symptom: API returns 500 error with “Error de conexión a la base de datos”Possible Causes:
- MySQL server is not running
- Incorrect database credentials
- Database does not exist
Error: Table doesn't exist
Error: Table doesn't exist
Symptom: SQL error “Table ‘prostocktool.bodegas’ doesn’t exist”Solution: Run the database migration scripts to create required tables.
Create bodegas table
Create categorias table
Create proveedores table
Create usuarios table
Error: Foreign key constraint fails
Error: Foreign key constraint fails
Symptom: Cannot delete record due to foreign key referencesExample Error: “No se puede eliminar. Tiene 5 producto(s) asociado(s)”This is expected behavior - the application prevents deletion of records that have related data.Solutions:
- Delete or reassign related records first
- If testing, use CASCADE delete (not recommended for production):
For testing only
CORS and API Issues
CORS error in browser console
CORS error in browser console
Symptom: Console shows “Access-Control-Allow-Origin” errorCause: Missing or incorrect CORS headers in PHP endpointsSolution: Verify all PHP files have proper CORS headers:
Required headers
In production, replace
* with your specific domain:API returns HTML instead of JSON
API returns HTML instead of JSON
Symptom: JavaScript console shows “Unexpected token < in JSON”Causes:
- PHP syntax error
- Incorrect file path
- PHP not parsing (served as plain text)
Fetch request fails silently
Fetch request fails silently
Symptom: No data loads, no error messagesSolution: Add comprehensive error handling:
Proper error handling
Frontend Issues
Modal not opening
Modal not opening
Symptoms:Verify CSS:
- Click button, nothing happens
- Modal appears but can’t interact
- Check CSS class
- Event listener timing
- Z-index issues
Form validation not working
Form validation not working
Issue: Form submits without validationCause: Missing
preventDefault() or validation logicSolution:Proper form handling
Search/filter not working
Search/filter not working
Issue: Typing in search box doesn’t filter resultsSolutions:
Check event listener
Verify filter logic
Edit button not populating form
Edit button not populating form
Styling Issues
CSS not loading
CSS not loading
Symptoms:
- Page shows unstyled HTML
- Browser console shows 404 for CSS files
Responsive layout broken
Responsive layout broken
Issue: Page doesn’t adapt to smaller screensSolution: Verify viewport meta tag:Add media queries:
Required in <head>
Performance Issues
Slow page load
Slow page load
Causes:
- Large number of database records
- Unoptimized queries
- Missing indexes
- Add database indexes
- Implement pagination
- Lazy load images
Memory leaks
Memory leaks
Symptom: Browser tab slows down over timeCause: Event listeners not removedSolution:
Clean up when needed
Deployment Issues
Works locally but not on server
Works locally but not on server
Character encoding issues (á, é, ñ)
Character encoding issues (á, é, ñ)
Symptom: Spanish characters display as �� or strange symbolsSolution: Ensure UTF-8 everywhere:
- Database
- PHP
- HTML
- Connection
Debugging Tools
Browser DevTools
Console: View JavaScript errorsNetwork: Monitor API requestsElements: Inspect HTML/CSSShortcut: F12
PHP Error Logs
XAMPP Windows:XAMPP Linux/Mac:
console.log() Debugging
Network Testing
Test API directly:Or use Postman/Insomnia
Getting Help
When reporting issues, include:
- Browser and version (Chrome 120, Firefox 115, etc.)
- Operating system (Windows 11, macOS 14, Ubuntu 22.04)
- PHP version (
php -v) - MySQL version (
mysql --version) - Error messages (exact text)
- Steps to reproduce
Project Structure
Review the folder organization
Coding Standards
Check code conventions and patterns