18

1 year agoby Dilshan Ramesh

Laravel Relationship Error

Dear Sarthak Sir, I'm using mySql database(xampp) for my works. i create relationship in migration file. but i can't migrate. it's generate this kind of error.

   Illuminate\Database\QueryException  : SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB
server version for the right syntax to use near ') default character set utf8mb4 collate 'utf8mb4_unicode_ci'' at line 1 (SQL: create table `reviews` () default character set utf8mb4 co
llate 'utf8mb4_unicode_ci')

  at E:\Projects\Laravel Projects\restful-api\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668| 

  Exception trace:

  1   PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for
the right syntax to use near ') default character set utf8mb4 collate 'utf8mb4_unicode_ci'' at line 1")
      E:\Projects\Laravel Projects\restful-api\vendor\laravel\framework\src\Illuminate\Database\Connection.php:452

  2   PDO::prepare("create table `reviews` () default character set utf8mb4 collate 'utf8mb4_unicode_ci'")
      E:\Projects\Laravel Projects\restful-api\vendor\laravel\framework\src\Illuminate\Database\Connection.php:452

  Please use the argument -v to see more details.

how can i fix this error? Thank you <3

80

Sarthak Shrivastava replied 1 year ago

1

Hey, there is some syntax error, check for any missing comma or bracket.

Ask Question
Most Visited
Categories