php的json输出中的未定义变量

I just don't get what's wrong in my code!

In browser, it shows that undefined variable!

But I declared it in a while loop before!

In browser it shows: Notice: Undefined variable: dhkBlood in C:\xampp\htdocs\JSONdata.php on line 371*

The PHP Code that I wrote is something like below:

if($retrieve1){
    while($row = mysql_fetch_assoc($retrieve1))
    {   
        $dhkBlood[] = array("ID" => $row['PID'], "PlaceName" => $row['PName'], "Address" => $row['Address'], "DeploymentName"  => $row['DName'], "Latitude" => $row['Latitude'], "Longitude" => $row['Longitude']);
    }
}

Code:

370. $result = array();
371. $result["dhakaBlood"]=$dhkBlood;
372. $finalResult = array();
373. $finalResult['data']=$result;
374. echo json_encode($finalResult);

P.S. $retrieve1 variable here is a variable that I used to assign a mysql query that generally retrieves information from my database!

Add

   $dhkBlood = array();

Before

 if($retrieve1){
  while($row = mysql_fetch_assoc($retrieve1))
   {   
    $dhkBlood[] = array("ID" => $row['PID'], "PlaceName" => $row['PName'], "Address" => $row['Address'], "DeploymentName"  => $row['DName'], "Latitude" => $row['Latitude'], "Longitude" => $row['Longitude']);
   }
  }
$dhkBlood = array(); //defined array first 
if($retrieve1){

    while($row = mysql_fetch_assoc($retrieve1)) {

        $dhkBlood[ID] = $row['PID'];
        $dhkBlood[PlaceName] = $row['PName'];
        $dhkBlood[Address] = $row['Address'];
        $dhkBlood[DeploymentName] = $row['DName'];
        $dhkBlood[Latitude] = $row['Latitude'];
        $dhkBlood[Longitude] = $row['Longitude'];

    }

}

defined array before use, and assign value in array as above,