意外的文件结束错误,任何人都可以教/建议代码



出现这个意外的文件结尾错误并找到错误,任何人对此代码的建议/帮助主要是关闭并得到相同的错误。

<?php 
$connect = mysqli_connect("localhost", "root", "", "funrun");
$output = '';
if(isset($_POST["export_excel"]))
{
    $sql = "SELECT * FROM registered ORDER BY fname DESC";
    $result = mysqli_query($connect, $sql);
    if(mysqli_num_rows($result) > 0)
    {
        $output .= '
            <table class="table" bordered="1">
                <tr>
                    <th>First Name</th>
                    <th>Middle Name</th>
                    <th>Last Name</th>
                    <th>Address</th>
                    <th>Age</th>
                    <th>Gender</th>
                    <th>BIB NO.</th>
                    <th>Category</th>
                </tr>
            ';
            while($row = mysqli_fetch_array($result))
            {
                $output .= '
                <tr>
                    <td>'.$row["fname"].'</td>
                    <td>'.$row["mname"].'</td>
                    <td>'.$row["lname"].'</td>
                    <td>'.$row["address"].'</td>
                    <td>'.$row["age"].'</td>
                    <td>'.$row["gender"].'</td>
                    <td>'.$row["bib_no"].'</td>
                    <td>'.$row["category"].'</td>
                </tr>
            ';
        }
        $output .= '</table>';
        header("Content-Type: application/xls");
        header("Content-Disposition: attachment; filename=download.xls);
        echo $output;
    }
}
?>

任何人有建议和意见请评论(仍然在这里学习(

你在 header(( 中丢失了一个 ' " '。

header("Content-Disposition: attachment; filename=download.xls);应该是

header("Content-Disposition: attachment; filename=download.xls");

相关内容

最新更新