Query SQL in my Controller does not run on Server Error 1142

Asked

Viewed 61 times

1

I created a website with Laravel 5.7, and uploaded to the server with the databases, all ok. All functions of my controller perform perfectly, except the Function down below:

public function consolidatedByMonth()
{
    $vistoriasAll = DB::select('SELECT CONCAT(MONTH(data),"-", YEAR(data)) as month, SUM(valor) as value FROM vistorias WHERE user_id="'.Auth::user()->id.'"GROUP BY MONTH(data);');
    $vistorias = collect($vistoriasAll)->reverse();

    return view('vistorias.listamensal')->with('vistorias', $vistorias);
}

When this Function is called by View, it returns the following error:

SQLSTATE[42000]: Syntax error or access Violation: 1142 SELECT command denied to user 'jcvis546_jcvisto'@'localhost' for table 'surveys' (SQL: SELECT CONCAT(MONTH(data),"-", YEAR(data)) as Month, SUM(value) as value FROM jcvistoria.vistorias GROUP BY MONTH(date);)

Can anyone help me what the cause of the mistake, and how to correct?

  • 1

    Your GROUP BY should not be: CONCAT(MONTH(data),"-", YEAR(data)) and not just by MONTH(date)?

  • I did as you suggested, and the error still persists, the same error. Strange because the user I am using has all the privileges.

  • @Augustovasques I don’t know how to do this yet... can you instruct me? I use the Hostgator cPanel

  • @Augusto Vasques my provider does not give access to the terminal... Can you explain to me better what you meant by creating an app with super user privileges(root)? You say an Laravel app?

  • 1

    Of a deal in this is from hostgator and talks about BD privileges. If you don’t resolve contact support.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.