我正在尝试从 phpmyadmin 数据库下载“.csv”,但它正在下载一些空白文件。相同的查询非常适用于 phpmyadmin 中的 sql。下面是代码:
function get_csv()
{
$filename="c:/mydata.csv";
$var=mysql_query("SELECT * INTO OUTFILE $filename FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\n\" FROM course");
header("Content-type: text/plain");
header("Content-Disposition: attachment; filename=$filename.xls");
header("Content-Transfer-Encoding: binary");
header("Pragma: no-cache");
header("Expires: 0");
//print "$header\n$data";
return 0;
}
在取消注释打印语句时,我得到一个显示一些错误的文件:
<br />
<b>Notice</b>: Undefined variable: header in <b>C:\xampp\htdocs\SEN_PROJECT_Latest\SEN-PROJECT\class\database.php</b> on line <b>485</b><br />
<br />
<b>Notice</b>: Undefined variable: data in <b>C:\xampp\htdocs\SEN_PROJECT_Latest\SEN-PROJECT\class\database.php</b> on line <b>485</b><br />