通过php表单下载后数据损坏

通过php表单下载后数据损坏,php,mysql,session,Php,Mysql,Session,下载时,我的输出应包含以下内容: <?php global $table; global $act; global $upload; if(!isset($_SESSION)) { session_start(); } include('db_connection.php'); if(isset($_POST['choose_lang'])) { $table = $_POST['choose_lang']; } if(isset($_POST['actio

下载时,我的输出应包含以下内容:

<?php
global $table;
global $act;
global $upload;

if(!isset($_SESSION)) 
{ 
    session_start(); 
}
include('db_connection.php');

if(isset($_POST['choose_lang']))
{ 
    $table = $_POST['choose_lang'];
 } 
if(isset($_POST['action']))
{
    $act = $_POST['action'];
    }
if(isset($_GET['upload']))
{
    $upload = $_GET['upload'];
    }
$upload = $_GET['upload'];

$_SESSION['upload'] = $upload;

$table = $_SESSION['choose_lang'];
$act=$_SESSION['action'];

   $query = "SELECT  *   FROM  $table WHERE upload = '".$_SESSION['upload']."' AND    category = '$act'" ;

 $result = mysql_query($query);
 $row = mysql_fetch_array($result, MYSQL_BOTH);
 $size = $row['filesize1'];

 $type = $row['filetype1'];
 $name =$row['filexml'];

 $text = $row['data1'];

 header("Content-length:".$size);
 header("Content-type:".$type);
 header("Content-Transfer-Encoding: Binary");
 header("Content-Disposition: attachment; filename=".$name);
 readfile("$text");
 echo $text;
 ?>
相反,当打开时,输出以记事本文件的形式出现:

   File type = "ooTextFile"
   Object class = "TextGrid"

   xmin = 0 
   xmax = 2.264331065759637 
   tiers? <exists> 
   size = 1 
   item []: 
   item [1]:
    class = "IntervalTier" 
    name = "vowels" 
    xmin = 0 
    xmax = 2.264331065759637 
    intervals: size = 5 
    intervals [1]:
        xmin = 0 
        xmax = 0.9286507897337561 
        text = "" 
    intervals [2]:
        xmin = 0.9286507897337561 
        xmax = 1.0970767840615319 
        text = "a" 
    intervals [3]:
        xmin = 1.0970767840615319 
        xmax = 1.2213912084463185 
        text = "" 
    intervals [4]:
        xmin = 1.2213912084463185 
        xmax = 1.447964272244398 
        text = "e" 
    intervals [5]:
        xmin = 1.447964272244398 
        xmax = 2.264331065759637 
        text = "" 

因此,我的文件被损坏。错误在哪里。请帮忙!!!!HTML主体来自哪里。

您可能有自动包含的锅炉板。从哪里调用此脚本?从php表单下载此textgrid文件。您发布的php脚本是表单的操作,我理解对吗?boiler plate只是指从某处复制的标准文本。非常感谢TIM是的,prblm与db_连接在一起。phpThnx TIM解决了html来自db_连接。php它是垃圾!!!!
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
   <title>Untitled Document</title>
    </head>

    <body>

    </body>
    </html>
     File type = "ooTextFile"
     Object class = "TextGrid"

      xmin = 0 
      xmax = 2.264331065759637 
      tiers? <exists> 
     size = 1 
  item []: 
 item [1]:
    class = "IntervalTier" 
    name = "vowels" 
    xmin = 0 
    xmax = 2.264331065759637 
    intervals: size = 5 
    intervals [1]:
        xmin = 0 
        xmax = 0.9286507897337561 
        text = "" 
    intervals [2]:
        xmin = 0.9286507897337561 
        xmax = 1.0970767840615319 
        text = "a" 
    intervals [3]:
        xmin = 1.0970767840615319 
        xmax = 1.2213912084463185 
        text = "" 
    intervals [4]:
        xmin = 1.2213912084463185 
        xmax = 1.447964272244398 
        text = "e" 
    intervals [5]:
        xmin = 1.447964272244398 
        xmax = 2.264331065759637 
        text = ""