Laravel 5 – SQLSTATE[22P02] – invalid text representation with postgres

Error:

SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input
syntax for integer: “dismissnotification” (SQL: select * from “users”
where “id” = dismissnotification)

In my routes.php file:

Route::get('user/dismissnotification/{notificationid}',array('as' => 'dismissnotification', 'uses' => 'NotificationController@dismiss'));

The link with the route on my view:

 <a href="{{ URL::route('dismissnotification',$notification->id)}}">  <i class="fa fa-times"></i> </a>

When I click on this link the page is redirected correctly to (for example):
http://mywebsite/user/dismissnotification/222222225

And the function “dismiss” on my NotificationController is empty, but the error persists. I have no idea where the select * from "users" in the original error comes from.

public function dismiss($notificationid) {
        //
}

Am I missing something obvious? What might be causing this error if there is no code at all in my function and the route is apparently correct?

Thanks in advance for your help.


Source: syntax

1 Comment

  1. Edwin

    The SQL query shows that Laravel is calling a different controller method on your route than you are expecting.

    select * from “users” where “id” = dismissnotification
    That query is trying to find a user with the ID matching ‘dismissnotification’, so it looks like it’s hitting something like UsersController@show or UsersController@edit or maybe even UsersController@222222225 depending on what other routes you have defined for /user.

    Since URL::route() rendered the path as you expected, your issue is probably the order in which you defined your routes; however, without seeing all of your /user routes and in the order you defined them, I can not be more specific.

    Reply

Leave a Reply