What could be causing the alternative image to display when a user is logged in but no profile picture is stored in the database?

The issue could be caused by a default image being displayed when the user is logged in but no profile picture is stored in the database. To solve this, you can check if the user has a profile picture stored in the database, and if not, display a default image instead.

// Check if user has a profile picture stored in the database
if (!empty($user['profile_picture'])) {
    // Display user's profile picture
    echo '<img src="' . $user['profile_picture'] . '" alt="Profile Picture">';
} else {
    // Display default image
    echo '<img src="default_image.jpg" alt="Default Image">';
}