<?php
/**
 * Test script to identify specific staging errors
 * Quick diagnostic for 500 error on Find a Trainer page
 */

// Basic PHP error check
ini_set('display_errors', 1);
ini_set('log_errors', 1);
error_reporting(E_ALL);

echo "Testing staging deployment issues...\n";

// Test 1: Check if critical PHP extensions are available
echo "1. PHP Extensions:\n";
$extensions = ['mysqli', 'curl', 'json', 'mbstring'];
foreach ($extensions as $ext) {
    echo "   {$ext}: " . (extension_loaded($ext) ? "LOADED" : "MISSING") . "\n";
}

// Test 2: Memory and configuration
echo "\n2. PHP Configuration:\n";
echo "   Memory Limit: " . ini_get('memory_limit') . "\n";
echo "   PHP Version: " . PHP_VERSION . "\n";
echo "   Error Reporting: " . ini_get('error_reporting') . "\n";
echo "   Max Execution Time: " . ini_get('max_execution_time') . "\n";

// Test 3: Basic file system access
echo "\n3. File System:\n";
echo "   Current Directory: " . getcwd() . "\n";
echo "   Script Path: " . __FILE__ . "\n";
echo "   Is Readable: " . (is_readable(__FILE__) ? "YES" : "NO") . "\n";

// Test 4: Database connection simulation
echo "\n4. Database Connection Test:\n";
$host = 'localhost';
$port = 3306;
$connection = @fsockopen($host, $port, $errno, $errstr, 5);
if ($connection) {
    echo "   MySQL Connection: AVAILABLE\n";
    fclose($connection);
} else {
    echo "   MySQL Connection: FAILED - {$errstr} ({$errno})\n";
}

echo "\nTest completed - check for any PHP errors above.\n";
?>
