![]() 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/.cursor-server/data/User/History/-3195476c/ |
<?php
session_start();
$_SESSION['user_id'] = 1;
require_once 'config/database.php';
$pdo = getDBConnection();
$user_id = $_SESSION['user_id'];
echo "Testing notifications query...\n";
try {
$stmt = $pdo->prepare("
SELECT
'friend_request' as type,
uf.created_at as created_at,
u.name as sender_name,
u.name as sender_username,
uf.friend_id as sender_id,
NULL as track_id,
NULL as track_title,
'sent you a friend request' as message
FROM user_friends uf
JOIN users u ON uf.user_id = u.id
WHERE uf.friend_id = ? AND uf.status = 'pending'
UNION ALL
SELECT
'like' as type,
tl.created_at as created_at,
u.name as sender_name,
u.name as sender_username,
tl.user_id as sender_id,
mt.id as track_id,
mt.title as track_title,
CONCAT('liked your track \"', mt.title, '\"') as message
FROM track_likes tl
JOIN users u ON tl.user_id = u.id
JOIN music_tracks mt ON tl.track_id = mt.id
WHERE mt.user_id = ? AND tl.user_id != ?
UNION ALL
SELECT
'comment' as type,
tc.created_at as created_at,
u.name as sender_name,
u.name as sender_username,
tc.user_id as sender_id,
mt.id as track_id,
mt.title as track_title,
CONCAT('commented on your track \"', mt.title, '\"') as message
FROM track_comments tc
JOIN users u ON tc.user_id = u.id
JOIN music_tracks mt ON tc.track_id = mt.id
WHERE mt.user_id = ? AND tc.user_id != ?
ORDER BY created_at DESC
LIMIT 50
");
echo "Query prepared successfully\n";
$stmt->execute([$user_id, $user_id, $user_id, $user_id, $user_id]);
echo "Query executed successfully\n";
$notifications = $stmt->fetchAll();
echo "Found " . count($notifications) . " notifications\n";
foreach ($notifications as $notification) {
echo "- " . $notification['type'] . ": " . $notification['message'] . "\n";
}
} catch (PDOException $e) {
echo "ERROR: " . $e->getMessage() . "\n";
echo "Error code: " . $e->getCode() . "\n";
}
?>