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才对。


哎 ,这错误。

  • 2020-12-02 22:56:09

    android设置禁止横屏失效崩溃

    误区,其实这两个代码都不是禁止横屏的,可以说根本没有禁止横屏的代码,这两个代码是设置竖屏的。 并且安卓先检测xml代码,如果是竖屏就直接展示竖屏的,但是如果java代码中设置的横屏,他会先展示竖屏咱展示横屏的 。

  • 2020-12-03 10:43:18

    xshell 连接 wsl

    装上 ubuntu on windows 后,默认要先打开 cmd, 再运行 bash 进入 ubuntu 的 shell。 但是这个shell很难看,配色不好就算了,还存在各种复制粘贴麻烦、默认没进入 home 目录、各种报警声等问题。所以尝试用 xshell 登陆 ubuntu

  • 2020-12-03 10:48:41

    在window10和Linux子系统 WSL如何互传文件

    想将 window下下载的文件上传到 linux 子系统中,如何用命令实现,其实可以将文件直接拖拽到 linux 在window下的目录即可(C:\Users\yunan.hu\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\rootfs)但是在linux下用命令怎么实现呢?

  • 2020-12-03 16:25:34

    WSL安装及升级WSL2

    幸好我们有了WSL(Windows Subsystem for Linux),顾名思义就是Windows中可以用Linux了,当然命令也会丰富更多,尤其是WSL2的发布,使得更多原来只能在Linux中做的事情现在也可以在Windows中干了。那么接下来我们就分别介绍WSL和WSL2的安装。