Problem with PHP code in latest PHP version

I am helping out a friend on his website and there are problems upgrading to the latest version of PHP… I feel like the problem is in the code below… I can’t seem to work it out. Any suggestions? Thank you in advance!

                $args = array(
                    'category_name' => news,
                $newsQuery = new WP_Query($args);
                if ($newsQuery->have_posts()) : while ($newsQuery->have_posts()) : $newsQuery->the_post();

                    <div class="col-lg-4 col-md-6 mb-3">
                        <div class="card">
                            <div class="card-img"
                                 style="background-image: url('<?php echo wp_get_attachment_url(get_post_thumbnail_id($post->ID)); ?>');"></div>
                            <div class="card-body">
                                <h5 class="card-title"><?php the_title() ?></h5>
                                <p class="card-text"><?php echo excerpt(10) ?></p>
                                <a href="<?php the_permalink() ?>" class="btn btn-primary">
                                    View more

                <?php endwhile; else : ?>

                    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>

                <?php endif; ?>
Sponsor our Newsletter | Privacy Policy | Terms of Service