dongzai5181 2018-03-22 14:08
浏览 318
已采纳

可能编码错误,格式错误的UTF-8字符

I am trying to fetch the records in laravel then it will give me following error.

Malformed UTF-8 characters, possibly incorrectly encoded

This is my code

$Login = DB::table('usermaster')

        ->where('Email', $uname)

        ->where('Password', md5($password))

        ->get();

    return response()->json($Login);
  • 写回答

1条回答 默认 最新

  • doukesou4452 2018-03-23 13:35
    关注

    In my laravel query i am use a following code so it will give a this type of error...

    Malformed UTF-8 characters, possibly incorrectly encoded

    $BvoData = DB::table('test1')->select('test1.*')
            ->where("test1.Id", "".$id."")
            ->first();
    
    $BvoData->temp1 = DB::table('temp1')->where('tmpdata', $BvoData->tmpdata)->get(); 
    
    $BvoData->temp2 = DB::table('temp2')->where('Id', $id)->get();
    
    return response()->json($BvoData);
    

    but i will solve this error by doing following code...

    $BvoData = DB::table('test1')->select('test1.*')
            ->where("test1.Id", "".$id."")
            ->first();
    
    $BvoData = (array)  $BvoData;
    
    $BvoData->temp1 = DB::table('temp1')->where('tmpdata', $BvoData->tmpdata)->get(); 
    
    $BvoData["temp1"] = json_decode(json_encode($BvoData["temp1"]), True);
    
    
    $BvoData->temp2 = DB::table('temp2')->where('Id', $id)->get();
    
    $BvoData["temp2"] = json_decode(json_encode($BvoData["temp2"]), True);
    
    return response()->json($BvoData);
    

    by using json_decode and json_encode i solve my problem...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 WPF动态创建页面内容
  • ¥15 如何对TBSS的结果进行统计学的分析已完成置换检验,如何在最终的TBSS输出结果提取除具体值及如何做进一步相关性分析
  • ¥15 SQL数据库操作问题
  • ¥100 关于lm339比较电路出现的问题
  • ¥15 Matlab安装yalmip和cplex功能安装失败
  • ¥15 加装宝马安卓中控改变开机画面
  • ¥15 STK安装问题问问大家,这种情况应该怎么办
  • ¥15 关于罗技鼠标宏lua文件的问题
  • ¥15 halcon ocr mlp 识别问题
  • ¥15 已知曲线满足正余弦函数,根据其峰值,还原出整条曲线