0
votes

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

1 Answers

1
votes

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