Question

I'm getting a fatal error that seems to makes no sense to me on the global $companies variable... Any thoughts?

Error:

Symfony \ Component \ Debug \ Exception \ FatalErrorException
syntax error, unexpected '=', expecting ',' or ';'

Code:

public function getCreate(){
            $view = View::make('account.create');
            global $companies = DB::table('homes')->select('Company')->distinct()->get(array());
            return $view->with('companies', $companies)->with('home_names', $home_names);
        }
Was it helpful?

Solution

The global keyword can only be use to declare global scope for a variable. You cannot simultaneously use an operator on that variable in the same statement.

So, try this instead:

global $companies;
$companies = DB::table('homes')->select('Company')->distinct()->get(array());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top