语法错误,意外''类型''<t_constant_encapsed_string> </t_constant_encapsed_string>

时间:2014-06-13 14:02:47

标签: php syntax-error

正如标题所说,我收到错误:

  

语法错误,意外''类型''期待...... \ AccountTableSeeder.php在线:12

我的AccountTableSeeder:

<?php

class AccountTableSeeder extends Seeder {

    public function run()
    {
        DB::table('account')->delete();
        User::create(array(
            'name' => 'admin2',
            'passwd' => Hash::make('0x,admin')
            'usertype' => '1'
            'money' => '1000'
            'id' => '1'
            'email' => 'admin@example.com'
            'isTest' => ''
            'secretquestion' => ''
            'secretanswer' => ''
            'registerip' => '192.168.0.0'
            'regdate' => '2014-13-06 15:07:00.333'
        ));
    }

}

我的create_account_table

    <?php

    use Illuminate\Database\Schema\Blueprint;
    use Illuminate\Database\Migrations\Migration;

    class CreateAccountTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('account', function(Blueprint $table)
        {
            $table->char('name', 16)->unique();
            $table->string('passwd');
            $table->integer('usertype');
            $table->integer('money');
            $table->increments('id');
            $table->string('email');
            $table->tinyInteger('isTest');
            $table->mediumText('secretquestion');
            $table->mediumText('secretanswer');
            $table->text('registerip');
            $table->dateTime('regdate');
            $table->unique( array('email','name','id') );
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::create('account', function(Blueprint $table)
        {
            //
        });
    }

}

我试图使用commane:php artisan db:seed 我希望你能帮助我:)。

1 个答案:

答案 0 :(得分:2)

您的数组值后缺少逗号:

public function run()
{
    DB::table('account')->delete();
    User::create(array(
        'name' => 'admin2',
        'passwd' => Hash::make('0x,admin'),
        'usertype' => '1',
        'money' => '1000',
        'id' => '1',
        'email' => 'admin@example.com',
        'isTest' => '',
        'secretquestion' => '',
        'secretanswer' => '',
        'registerip' => '192.168.0.0',
        'regdate' => '2014-13-06 15:07:00.333'
    ));
}

仅供参考,一个体面的IDE会为您捕捉到这一点并立即提醒您错误。