将 MySQL 下载为 CSV 时出现问题
我在将 mysql 数据库输出到 csv 文件并下载它时遇到问题。以下代码在第 3 行产生错误 “unexpected T_CONSTANT_ENCAPSED_STRING”
。我已经在第三行和第四行尝试过使用分号和不使用分号。
$FileName = "/googleresearch" . abs(rand(0,1000000000000)) . ".csv";
$query = "SELECT * FROM happyturtle INTO OUTFILE $FileName;
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"';
LINES TERMINATED BY '\n'";
$result = mysql_query($query) or die(mysql_error());
exit;
I am having trouble outputting a mysql database into a csv file and downloading it. The bellow code produces the error "unexpected T_CONSTANT_ENCAPSED_STRING"
on the 3rd line bellow. I have tried it with semicolons and without on the 3rd and 4th lines.
$FileName = "/googleresearch" . abs(rand(0,1000000000000)) . ".csv";
$query = "SELECT * FROM happyturtle INTO OUTFILE $FileName;
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"';
LINES TERMINATED BY '\n'";
$result = mysql_query($query) or die(mysql_error());
exit;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在第四行转义您的
"
,例如:You need to escape your
"
on the fourth line like: