我正在尝试使用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;
}
}
答案 0 :(得分:1)
你需要逃避你的报价 - 或者更容易..切换到单引号,然后逃避它们(其中少了!)
$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\'';