Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lukefrost2020's avatar

Syntax error, unexpected ')', expecting ';' or ','

I am outputting a foreach loop using the compact variable from my Products Controller in a blade file but it keeps coming up with an error in the view that doesn't make sense.

'''

          @foreach($products as $product)
           <tr>
               <td style="width:50px; border: 1px solid #333;"><img class="card-img-top img-fluid" src="{{url('images',$product->image)}}" width="50px" alt="Card image cap"></td>
               <td style="width:50px;">{{$product->id}}</td>
               <td style="width:50px;">{{$product->product_name)}}</td>
               <td style="width:50px;">{{$product->product_code}}</td>
               <td style="width:50px;">{{$product->product_price}}</td>
               <td style="width:50px;">{{$product->category_id}}</td>
               <td><a href="{{route('ProductEditForm',$product->id)}}" class="btn btn-success btn-small">Edit</a></td>
               {!! Form::open(['method' => 'DELETE' 'action' => ['ProductsController@destroy', $product->id]]) !!}
                  <td>{!! Form::submit('Delete Product', ['class' => 'btn btn-danger col-sm-6']) !!}</td>


               {!! Form::close() !!}
           </tr>
           @endforeach

'''

The error appears on the line with the image in although I'm not sure why. Not sure whether this is related to the view or controller?

0 likes
14 replies
Snapey's avatar

This could be due to some blade not terminated correctly earlier in the page

ZhuYi's avatar
{!! Form::open(['method' => 'DELETE', 'action' => ['ProductsController@destroy', $product->id]]) !!}
lukefrost2020's avatar

Didn't even notice the error with that, fixed that now but the same error remains for the page.

lukefrost2020's avatar

Here is the full blade file:


@extends('admin.master')

@section('content')


<main class="col-sm-9 ml-sm-auto col-md-10 pt-3" role="main">
<h3>Products</h3>

<ul>






    <!-- INVERSE/DARK TABLE -->
       <table class="table table-dark">
           <thead>
               <tr>
                   <th>Image</th>
                   <th>Product Id</th>
                   <th>Product Name</th>
                   <th>Product Code</th>
                   <th>Product Price</th>
                   <th>Category Id</th>
                   <th>Update</th>
               </tr>
           </thead>

           <tbody>

              @foreach($products as $product)
               <tr>
                   <td style="width:50px; border: 1px solid #333;"><img class="card-img-top img-fluid" src="{{url('images',$product->image)}}" width="50px" alt="Card image cap"></td>
                   <td style="width:50px;">{{$product->id}}</td>
                   <td style="width:50px;">{{$product->product_name)}}</td>
                   <td style="width:50px;">{{$product->product_code}}</td>
                   <td style="width:50px;">{{$product->product_price}}</td>
                   <td style="width:50px;">{{$product->category_id}}</td>
                   <td><a href="{{route('ProductEditForm',$product->id)}}" class="btn btn-success btn-small">Edit</a></td>
                   {!! Form::open(['method' => 'DELETE', 'action' => ['ProductsController@destroy', $product->id]]) !!}
                      <td>{!! Form::submit('Delete Product', ['class' => 'btn btn-danger col-sm-6']) !!}</td>


                   {!! Form::close() !!}
               </tr>
               @endforeach
           </tbody>
       </table>


</main>

@endsection

Snapey's avatar

Please format your code by putting 3 backticks ``` on a line before and after each code block

lukefrost2020's avatar

How do I edit the existing post with the code in to do this. I can't find an edit feature that lets me change it to include the backticks.

Snapey's avatar

when you hover over your post, three dots appear at the bottom. hover over these and an edit option appears.

Snapey's avatar

Other pages that extend admin.master work ok?

lukefrost2020's avatar

Yeah checked all the pages and they work fine other than this one.

Snapey's avatar

does the full error give any more clues ?

If using Laravel 7, you can share the error

lukefrost2020's avatar

Not really, it's on the image section in the table and I can't understand why. And Yes I've just shared the error.

lukefrost2020's avatar

Not sure whether this could be connected to the Products Controller although I can't anything wrong with it in there.

Snapey's avatar

Yes I've just shared the error.

?

Please or to participate in this conversation.