【发布时间】:2017-11-06 19:56:51
【问题描述】:
我正在使用 Laravel 5.4 开发学校管理系统。当我迁移数据库表时,我收到此错误消息:
[Symfony\Component\Debug\Exception\FatalThrowableError] 解析错误: 语法错误,意外的 '100' (T_LNUMBER),需要 ',' 或 ')'
请帮帮我,我该如何解决这个错误?
迁移:
public function up() {
Schema::create('students', function (Blueprint $table) {
$table->increments('student_id'); $table->string('first_name',50); $table->string('last_name',50); $table->date('dob');
$table->string('100')->nullable(); $table->string('status');
$table->string('current_address',255)->nullable();
$table->foreign('user_id')->references('user_id')->on('users');
//$table->timestamps();
}); }
【问题讨论】:
-
我尝试了很多次并检查我的表架构
-
我的意思是请与我们分享您的一些工作。
-
是数据库表 public function up() { Schema::create('students', function (Blueprint $table) { $table->increments('student_id'); $table-> string('first_name',50); $table->string('last_name',50); $table->date('dob'); $table->string('100')->nullable(); $ table->string('status'); $table->string('current_address',255)->nullable(); $table->foreign('user_id')->references('user_id')->on( 'users'); //$table->timestamps(); }); }
-
不要将其添加为评论,编辑您的问题并在此处添加迁移文件。
-
在括号中命名 $table->string('100')->nullable();示例:string('name',100)