Home » Php » Json response give null response, when it having multiple lines with spaces

Json response give null response, when it having multiple lines with spaces

Posted by: admin June 30, 2018 Leave a comment

Questions:

I want to print JSON response which include following data from one column
‘Work plan

Date – 24/05/2018
Project Name :- Lanning NH-06 package-IIA Chikhali – Tarsode section @ chainage 390+000 to 422+000 KM.
Agency Name :- PVS Private Limited
Department Name :- Survey

Sr. No. Name of Work    Chainage    Target Achieved (m) Surveyor
Name
        From    To      
1   TBM level Carring 
    GPS No  391/A   399/A       Mr. Deepak
2   TBM level Carring 
    GPS No  399/A   391/A       Mr. Govind
3   Pcc marking @ Ch – 
    395 + 760           Mr. Jeevan
4   TBM carring GPS No.
    399/A   403/A       Mr. Krishna
6   Utility Survey  397 + 250           Mr. Rakesh
7   C & G   422 + 100           Mr. Anil Mukate
Mr. Dhyaneshwer Ingale
8   Roadside Temporary Barring              Mr. Amol Karade

But JSON response show null response, when it having multiple lines of data with spaces. Response is proper for those who having 2 to 3 line.

 <?php  
        require('connection.php');  
        $project="Jalgaon NH6";
        $depart="Survey";
        // Check connection
        if ($conn->connect_error) {
          die("Connection failed: " . $conn->connect_error);
        } 
        else
        {
         $productQry = "select * from tbl_dailyworksheet where projectname='$project' and  departmentname='$depart' ";   $sql1=mysqli_query($conn,$productQry);
          while($row=mysqli_fetch_assoc($sql1))
         {
          $arr[] = $row;            
         }
        }
         echo json_encode($arr);        
        ?>  
Answers: