Reputation: 9731
I keep trying to run this function and I have rewritten it in all ways possible, but I cannot get it work:
public function backup($location) {
$database = 'logindb';
$backup = $location.'/'.$database.'_backup_'.date('Y').'_'.date('m').'_'.date('d').'.sql';
$sql = "SELECT * INTO OUTFILE '$backup' FROM users";
if ($stmt = $this->connect->prepare($sql)){
if ($stmt->execute()) {
echo $stmt->error();
}
$stmt->close();
echo 'done';
} else {
echo 'Error';
}
}
What am I doing wrong or what could be wrong ?
Upvotes: 0
Views: 944
Reputation: 383
Type ps-Af to see what is the username of your webserver (usually apache or httpd) Then type chown -R apache:apache (or httpd respactively) in one folder up your backup directory Then type chmod u+w I think that since webserver tries to write the file, it must have write permissions
Upvotes: 2