2016-04-06 168 views
2

在D:\ xampp \ htdocs \ guestlara \ app \ controllers \ LoginController中堆栈跟踪:异常'Symfony \ Component \ Debug \ Exception \ FatalErrorException'消息'syntax error,unexpected'}' .PHP:23laravel验证语法错误

public function login_user() 
{ 

    $rules = array(
        'email'=> 'Required|Between:3,64|Email|Unique:users', 
        'password'=>'Required|AlphaNum|Between:4,8|Confirmed', 
        ); 
    $validator = Validator::make(Input::all(), $rules); 

    if ($validator->fails()) { 

     // get the error messages from the validator 
     $messages = $validator->messages(); 

     // redirect our user back to the form with the errors from the validator 
     return Redirect::to('/') 
     ->withErrors($validator); 
     log::error($validator) 

    } 
    else 
    { 

     // attempt to do the login 
     if (Auth::attempt($users)) { 

      return Redirect::to('dashboard'); 

     } else {   

      return Redirect::to('/'); 

     } 

    } 


} 
+0

这是PHP语言的语法错误。这与Laravel及其验证都没有共同之处。 – Rolice

回答

4

缺少; -

 return Redirect::to('/') 
       ->withErrors($validator); 
     log::error($validator); // Here 

    } else { 

小的变化。

log::error($validator);将不会执行,因为该操作将在达到log::error()之前执行。因此,它应该是 - 在日志

log::error($validator); 
return Redirect::to('/') 
     ->withErrors($validator); 
0

缺少分号::错误($验证)

+0

为什么有人会downvote这个答案? – Rolice