简体   繁体   中英

possibly incorrectly encoded,Malformed UTF-8 characters

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);

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM