Unexpected data found. Unexpected data found. Data missing

2018-01-17 23:36:26

错误代码

public function write($category,Request $request)
{
   $title = UsedCarCategory::find($category)->name;
   $id = $request->input('id');

   $article = "";
   if($id==""){
       /*添加文章*/
   }else{

       $article = UsedCar::find($id);
   }

   return view('/usedCar/write',["article"=>$article,"title"=>$title,"category"=>$category]);
}

上面的代码,再正常不过了,不知道为啥出现了下面的错误

InvalidArgumentException
Unexpected data found. Unexpected data found. Data missing


从网上查出


up vote1down voteaccepted

You're passing null as a string instead of the datatype. Remove the quotes, and it will work:

$date = Carbon::createFromDate(null, rand(1,12), rand(1,28));
// object(Carbon\Carbon)(
//   'date' => '2017-06-02 10:28:17.000000',
//   'timezone_type' => 3,
//   'timezone' => 'America/New_York'
// )

Your next error, you're missing a second colon after DB:

DB::table('utilisateurs')->insert


我仔细检查我没有这个错误。


后来去数据库看,并不是我的错误,代码并没有错误。


created_at   我竟然设置成了time字段。

然后就报错了,不能查询出时间的原因,应该是timestamp才对。


哎 ,这错误。

  • 2021-01-05 15:41:42

    nodejs修改时区

    ​let date = new Date(); date.setHours(date.getHours() + 8);

  • 2021-01-06 23:09:38

    mp3解码器转PCM合并

    首先,为了混合两个音频文件,您需要操纵它们的原始表示;由于MP3文件被压缩,您无法直接访问信号的原始表示.您需要对压缩的MP3流进行解码,以便“理解”您的音频信号的波形,然后可以混合使用.

  • 2021-01-08 16:47:37

    nodejs如何使用fetch

    node 中没有实现 fetch,你可以使用 node-fetch,使得在 node 中也可以使用 fetch.

  • 2021-01-08 16:49:59

    CommonJs 与 ESModule区别

    node中模块导入require是一个内置的函数,因此只有在运行后我们才可以得知模块导出内容,无法做静态分析