query(\$sql);\n echo json_encode(['success'=>true,'broadcasts'=>\$stmt->fetchAll()]);\n } catch(Exception \$e) {\n echo json_encode(['success'=>false,'error'=>\$e->getMessage()]);\n }\n break;"; $c = substr($c, 0, $idx) . $new . substr($c, $end); file_put_contents($f, $c); // Verify it works require_once '/home/tomtomgames.com/includes/config.php'; require_once '/home/tomtomgames.com/includes/db.php'; try { $stmt = db()->query("SELECT COUNT(*) FROM broadcasts"); echo "OK - broadcasts in DB: " . $stmt->fetchColumn() . "\n"; $stmt2 = db()->query("SELECT b.id, b.subject, b.sent_at, u.username AS sender_name FROM broadcasts b JOIN users u ON b.admin_id=u.id ORDER BY b.sent_at DESC LIMIT 5"); $rows = $stmt2->fetchAll(); echo "Query works - rows: " . count($rows) . "\n"; foreach($rows as $r) echo " #{$r['id']}: {$r['subject']} by {$r['sender_name']}\n"; } catch(Exception $e) { echo "ERROR: " . $e->getMessage() . "\n"; } echo "DONE - delete this file\n";