JSON / PHP无法正常工作; 怎么调试?

I have a HTML/PHP(1) script with HTML controls which use JavaScript JSON and underlying PHP(2) script to generate a option list control in PHP(1) by querying a MySQL database.

The code is usually working (I made some changes today and it stopped working); however, I would like to display an error message from PHP(2) in the PHP(1) control. Obviously, using print in PHP(2) does not work.

A fragment of PHP(2) is:

[...]

// Get query ---------------------------------------------------

$query_data = mysqli_query($db_conn, $query);

if ($query_data == FALSE)
   {
   array_push($zona, 'QUERY_ERROR');
   goto _adr1;
   }

$rows = mysqli_num_rows($query_data);
if ($rows == 0)
   {
   array_push($zona, 'No Result(s) !');
   goto _adr1;
   }

// Build array -------------------------------------------------

while ($row = mysqli_fetch_array($query_data))
   {
   array_push($zona, $row['RezvZona']);
   }

// End ========================================================================

_adr1:
print json_encode($zona);

mysqli_free_result($query_data);
mysqli_close($db_conn);

?>

My first question: I get the 'No Result(s) !' string in my PHP(1) option list. However, if my query has syntax errors or is otherwise incorrect, I don't get the 'QUERY_ERROR' in the same option list - the list remains blank. Why ?

My second question: How can I debug the PHP(2) script ? I have XDebug - would that work ? Isn't there a more simple way - e.g. use the Firefox debugger ?