问题
I have the following function in my php file, and my script is putting on CPanel. I am sure the script has been executed, as the last print out has appeared, however my csv file does not. I have changed the permission of folder Log_report to 755, but still file cannot be created, how can I make change? I am sure the mysql script to create csv is correct, as I used the same script in my XAMPP local machine and successfully created a file in my machine before.
function export($DB){
$dbConnection = mysql_connect($DB['server'], $DB['loginName'], $DB['password']);
if(!$dbConnection){
die('Error! ' . mysql_error());
}
mysql_select_db($DB['database'], $dbConnection);
$timezone = "Asia/Hong_Kong";
if(function_exists('date_default_timezone_set'))
date_default_timezone_set($timezone);
$Time = date('Y_m_d_H_i');
$fileName = "/home/me/public_html/Log_Report/Report_".$Time.".csv";
$result = mysql_query("SELECT TechName, ClientName, SiteName, LogTime, Type
INTO OUTFILE '".$fileName."'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED by '\"'
LINES TERMINATED BY '\n'
FROM tech AS T, client AS C, site AS S, log AS L
WHERE T.TechID=L.TechID AND C.ClientID=L.ClientID AND S.SiteID=L.SiteID
ORDER BY L.LogTime DESC");
print "abcde";
}
回答1:
This thread should be helpful in explaining the mysql permission issue:
http://lists.mysql.com/mysql/206422
Also I should have asked what mysql user account you were running the query, as in root or another possibly limited user?
来源:https://stackoverflow.com/questions/11843456/cpanel-does-not-allow-using-script-to-create-file