gpt4 book ai didi

php - 使用php脚本将mysql数据输出到csv/txt文件

转载 作者:行者123 更新时间:2023-11-29 11:50:38 25 4
gpt4 key购买 nike

我正在尝试输出mysql列至txt -文件使用php脚本,查询在 mysql 上运行良好但在 php 上失败。单击按钮时,函数返回 Internal Server error .

function RsyncFTPAction() {
$sql = "SELECT CONCAT("sshpass -p ""Password"" rsync -avvtzh -e ""ssh -o StrictHostKeyChecking=no"" --log-file=""/home/toor/rsync2.log""", login,"@", ftp_addr, " :", camera_name,"/", "/",'home',"/",login, "/", camera_name)
FROM inteliviz.cameras order by id INTO OUTFILE '/tmp/wptitles2.csv' LINES TERMINATED BY '\r\n'";
$result = $conn->Execute($sql);
if(!$result) {
print $conn -> ErrorMsg(); ;
exit;
}
}

最佳答案

您需要转义引号 - 或者更简单......切换到单引号,并转义它们(它们更少!)

$sql = 'SELECT CONCAT("sshpass -p ""Password""  rsync   -avvtzh -e  ""ssh -o StrictHostKeyChecking=no""  --log-file=""/home/toor/rsync2.log""",   login,"@", ftp_addr, " :", camera_name,"/",    "/",`'home`',"/",login, "/", camera_name)
FROM inteliviz.cameras order by id INTO OUTFILE \'/tmp/wptitles2.csv\' LINES TERMINATED BY \'\r\n\'';

关于php - 使用php脚本将mysql数据输出到csv/txt文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34130848/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com