Prevent force download
<p>I am using the below mentioned code (get_data.php) to send JSON data to an AJAX call. I would like to include the same PHP file to get count($ret).
When I include this file am not able to get count($ret) but file gets downloaded forcefully.
If I remove "header("Content-type: text/json");" it works but I'll need it to send JSON response. Could anyone help me to avoid force download when this file is included?</p>

<p>get_data.php:</p>

<pre><code>&lt;?php
    header("Content-type: text/json");
    include('connect.php');
    global $conn;
    $site_id = $_GET['site_id'];
    $dbh = $conn-&gt;prepare('SELECT UNIX_TIMESTAMP(current_ts), response_time FROM site_response WHERE current_ts &gt;= DATE_SUB( NOW( ) , INTERVAL 30 MINUTE ) AND site_id ='.$site_id.'');
    $dbh-&gt;bindParam(':site_id', $site_id);
    $dbh-&gt;execute();
    $graph_data = $dbh-&gt;fetchAll();
    $ret = array();
        foreach($graph_data as $data)
        {
            $current_time = $data['UNIX_TIMESTAMP(current_ts)']*1000;
            $response_time = $data['response_time']*1;  
            $ret[] = array($current_time, $response_time);                  
        } 
        echo json_encode($ret);

    ?&gt;
</code></pre>
