Monday, February 26, 2018

mysql - Having An Issue Backing Up MY Database From Php

the issue that I'm having is with the fopen(), fwrite(), and fclose() function. This is the error I am receiving:



Warning: fopen(/db-backup-salisbury_school-20121128-021138.sql) [function.fopen]: failed to open stream: Permission denied in C:\inetpub\wwwroot\omarejaz\sbyschool\q5.php on line 177



Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\inetpub\wwwroot\omarejaz\sbyschool\q5.php on line 178



Warning: fclose() expects parameter 1 to be resource, boolean given in C:\inetpub\wwwroot\omarejaz\sbyschool\q5.php on line 179




The code for this portion of php can be found below any help would be greatly appreciated!



 * Save SQL to file
* @param string $sql
*/
protected function saveFile(&$sql, $outputDir = '.')
{
if (!$sql) return false;

try

{
$handle = fopen($outputDir.'/db-backup-'.$this->dbName.'-'.date("Ymd-His", time()).'.sql','w+');
fwrite($handle, $sql);
fclose($handle);
}
catch (Exception $e)
{
var_dump($e->getMessage());
return false;
}


return true;
}


}
?>

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...