我需要一些教育。每个月底,我想从我的网络服务器下载一些数据到我的本地 PC。所以,我为此编写了一个小脚本,它从数据库中选择数据。接下来,我想下载它。我试过这个:
$file=$month . '.txt';
$handle=fopen($file, "w");
header("Content-Type: application/text");
header("Content-Disposition: attachment, filename=" . $month . '.txt');
while ($row=mysql_fetch_array($res))
{
$writestring = $row['data_I_want'] . "\r\n";
fwrite($handle, $writestring);
}
fclose($handle);
如果我运行它,则创建文件,但我的文件不包含我想要的数据。相反,我从浏览器中的 HTML 文件中得到了转储。我做错了什么。谢谢,Xpoes