![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/soundstudiopro.com/public_html/ |
<?php
// Fix artist name issue for admin-created tracks
require_once 'config/database.php';
$pdo = getDBConnection();
echo "<h2>Fix Artist Name Issue</h2>";
// Check for tracks with missing artist names
$problem_tracks = $pdo->query("
SELECT mt.id, mt.title, mt.user_id, u.name as artist_name
FROM music_tracks mt
LEFT JOIN users u ON mt.user_id = u.id
WHERE u.name IS NULL AND mt.user_id IS NOT NULL
ORDER BY mt.created_at DESC
")->fetchAll();
if (!empty($problem_tracks)) {
echo "<h3>Found " . count($problem_tracks) . " tracks with missing artist names:</h3>";
foreach ($problem_tracks as $track) {
echo "<div style='border: 1px solid red; padding: 10px; margin: 10px;'>";
echo "<strong>Track ID:</strong> " . $track['id'] . "<br>";
echo "<strong>Title:</strong> " . htmlspecialchars($track['title']) . "<br>";
echo "<strong>User ID:</strong> " . $track['user_id'] . "<br>";
echo "<strong>Artist Name:</strong> " . htmlspecialchars($track['artist_name'] ?? 'NULL') . "<br>";
// Check if user exists
$user = $pdo->query("SELECT * FROM users WHERE id = " . $track['user_id'])->fetch();
if ($user) {
echo "<strong>User exists:</strong> " . htmlspecialchars($user['name']) . "<br>";
// Fix the track by updating the user_id to a valid admin user
$admin_user = $pdo->query("SELECT id, name FROM users WHERE is_admin = 1 LIMIT 1")->fetch();
if ($admin_user) {
$update_stmt = $pdo->prepare("UPDATE music_tracks SET user_id = ? WHERE id = ?");
$result = $update_stmt->execute([$admin_user['id'], $track['id']]);
if ($result) {
echo "<span style='color: green;'>✅ Fixed: Updated user_id to admin user (" . htmlspecialchars($admin_user['name']) . ")</span><br>";
} else {
echo "<span style='color: red;'>❌ Failed to update track</span><br>";
}
} else {
echo "<span style='color: red;'>❌ No admin user found to assign</span><br>";
}
} else {
echo "<span style='color: red;'>❌ User does not exist!</span><br>";
// Assign to admin user
$admin_user = $pdo->query("SELECT id, name FROM users WHERE is_admin = 1 LIMIT 1")->fetch();
if ($admin_user) {
$update_stmt = $pdo->prepare("UPDATE music_tracks SET user_id = ? WHERE id = ?");
$result = $update_stmt->execute([$admin_user['id'], $track['id']]);
if ($result) {
echo "<span style='color: green;'>✅ Fixed: Assigned to admin user (" . htmlspecialchars($admin_user['name']) . ")</span><br>";
} else {
echo "<span style='color: red;'>❌ Failed to assign to admin</span><br>";
}
} else {
echo "<span style='color: red;'>❌ No admin user found</span><br>";
}
}
echo "</div>";
}
} else {
echo "<h3>✅ No tracks with missing artist names found</h3>";
}
// Test the fix by checking recent tracks
echo "<h3>Recent Tracks After Fix:</h3>";
$recent_tracks = $pdo->query("
SELECT mt.id, mt.title, mt.user_id, u.name as artist_name
FROM music_tracks mt
LEFT JOIN users u ON mt.user_id = u.id
ORDER BY mt.created_at DESC
LIMIT 5
")->fetchAll();
foreach ($recent_tracks as $track) {
echo "<div style='border: 1px solid #ccc; padding: 10px; margin: 10px;'>";
echo "<strong>ID:</strong> " . $track['id'] . "<br>";
echo "<strong>Title:</strong> " . htmlspecialchars($track['title']) . "<br>";
echo "<strong>User ID:</strong> " . $track['user_id'] . "<br>";
echo "<strong>Artist Name:</strong> " . htmlspecialchars($track['artist_name'] ?? 'NULL') . "<br>";
echo "</div>";
}
// Test the global player query
echo "<h3>Global Player Query Test:</h3>";
$global_player_tracks = $pdo->query("
SELECT mt.*, u.name as artist_name
FROM music_tracks mt
JOIN users u ON mt.user_id = u.id
WHERE mt.status = 'complete' AND mt.audio_url IS NOT NULL
ORDER BY mt.created_at DESC
LIMIT 3
")->fetchAll();
foreach ($global_player_tracks as $track) {
echo "<div style='border: 1px solid blue; padding: 10px; margin: 10px; background: #e3f2fd;'>";
echo "<strong>Global Player Track:</strong><br>";
echo "<strong>Title:</strong> " . htmlspecialchars($track['title']) . "<br>";
echo "<strong>Artist:</strong> " . htmlspecialchars($track['artist_name']) . "<br>";
echo "<strong>User ID:</strong> " . $track['user_id'] . "<br>";
echo "</div>";
}
?>