Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Laravel 4 Basics Continuing CRUD Deleting & Destroy Data

Delete button not working

@extends('layouts/main')
@section('content')

    <h2>All Todo Lists</h2>
    <ul>
        @foreach ($todo_lists as $i)
            <li><h4>{{ link_to_route('todos.show', $i->name, array($i->id)) }}</h4></li>
            {{ link_to_route('todos.edit', 'edit', array($i->id), array('class' => 'btn btn-success btn-xs')) }}
            {{ Form::model($list, ['route' => ['todos.destroy', $list->id]] }}
                {{ Form::button('delete', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs']) }}
            {{ Form::close() }}
        @endforeach
    </ul>


@stop

syntax error, unexpected ';'

Help please ;)

9 Answers

<?php echo Form::model($list, ['route' => ['todos.destroy', $list->id]]; ?>

replace with:

<?php echo Form::model($list, ['route' => ['todos.destroy', $list->id]]); ?>

i think you may have a problem in layouts/main file, the error says you have somewhere semi-colom (;) where it shouldn't be...

if you need help please paste layouts/main code here ;)

Its somewhere here

            {{ Form::model($list, ['route' => ['todos.destroy', $list->id]] }}
                {{ Form::button('delete', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs']) }}
            {{ Form::close() }}

When I remove this code error disappears.

it may be a code on the Laravel core files, maybe it is corrupted files, try to download again and replace the files...

Which files?

the Laravel framework files...

vendor > laravel > framework? If so how do I delete and then reupload? Still a newb

can you send me the exact error?

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_PARSE) syntax error, unexpected ';' Open: /home/vagrant/Sites/laravel-basics/app/storage/views/16fe21f7337deb80a16dd974cacfdf46 <h2>All Todo Lists</h2> <ul> <?php foreach($todo_lists as $i): ?> <li><h4><?php echo link_to_route('todos.show', $i->name, array($i->id)); ?></h4></li> <?php echo link_to_route('todos.edit', 'edit', array($i->id), array('class' => 'btn btn-success btn-xs')); ?>

        <?php echo Form::model($list, ['route' => ['todos.destroy', $list->id]]; ?>

            <?php echo Form::button('delete', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs']); ?>

Server/Request Data APP_ENV local USER vagrant HOME /home/vagrant FCGI_ROLE RESPONDER QUERY_STRING
REQUEST_METHOD GET CONTENT_TYPE
CONTENT_LENGTH
SCRIPT_FILENAME /home/vagrant/Sites/laravel-basics/public/index.php SCRIPT_NAME /index.php REQUEST_URI / DOCUMENT_URI /index.php DOCUMENT_ROOT /home/vagrant/Sites/laravel-basics/public SERVER_PROTOCOL HTTP/1.1 GATEWAY_INTERFACE CGI/1.1 SERVER_SOFTWARE nginx/1.6.2 REMOTE_ADDR 10.0.2.2 REMOTE_PORT 65485 SERVER_ADDR 10.0.2.15 SERVER_PORT 80 SERVER_NAME laravel.dev REDIRECT_STATUS 200 HTTP_HOST laravel.dev:8000 HTTP_CONNECTION keep-alive HTTP_CACHE_CONTROL max-age=0 HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8 HTTP_USER_AGENT Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.101 Safari/537.36 HTTP_ACCEPT_ENCODING gzip,deflate,sdch HTTP_ACCEPT_LANGUAGE en-GB,en-US;q=0.8,en;q=0.6 HTTP_COOKIE laravel_session=eyJpdiI6ImZab1pZTXFjQVpSRG9DekRlbXM3TkE9PSIsInZhbHVlIjoiMzBEXC9mcklTWlpmV0JjRG9KMTFaR01xaUlcL3N3bElBd044aU93K1phY0hWRVB3d241WTNqUUxmKzFNNmZDcjhzaXBzcWNHSjJkQ1BKeStnYTJYNVBEdz09IiwibWFjIjoiZTVhMjc0NTllMDA1MWEzYzM5NDEwYTUzZmNlYTM1OGI2ZmRkMmNhZDJhYzRlZGQ4M2QyYzk2MTJjMWViY2I4ZSJ9 PHP_SELF /index.php REQUEST_TIME_FLOAT 1413282313.1674 REQUEST_TIME 1413282313 GET Data empty POST Data empty Files empty Cookies laravel_session eyJpdiI6ImZab1pZTXFjQVpSRG9DekRlbXM3TkE9PSIsInZhbHVlIjoiMzBEXC9mcklTWlpmV0JjRG9KMTFaR01xaUlcL3N3bElBd044aU93K1phY0hWRVB3d241WTNqUUxmKzFNNmZDcjhzaXBzcWNHSjJkQ1BKeStnYTJYNVBEdz09IiwibWFjIjoiZTVhMjc0NTllMDA1MWEzYzM5NDEwYTUzZmNlYTM1OGI2ZmRkMmNhZDJhYzRlZGQ4M2QyYzk2MTJjMWViY2I4ZSJ9 Session empty Environment Variables empty Registered Handlers

  1. Whoops\Handler\PrettyPageHandler

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_PARSE) syntax error, unexpected ';'

<h2>All Todo Lists</h2>
    <ul>
        <?php foreach($todo_lists as $i): ?>
            <li><h4><?php echo link_to_route('todos.show', $i->name, array($i->id)); ?></h4></li>
            <?php echo link_to_route('todos.edit', 'edit', array($i->id), array('class' => 'btn btn-success btn-xs')); ?>

            <?php echo Form::model($list, ['route' => ['todos.destroy', $list->id]]; ?>

                <?php echo Form::button('delete', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs']); ?>

You are an absolute legend. Can't believe I did not see the missing bracket. Fixed it :)

Thank you so much.

i can't believe i didn't see it either...

Enjoy and Good luck with the development :)