I’ve got a site hosted with 1and1 – who are useless! For some reason the backup scripts they provide no longer work and they can’t provide me with an answer! So I thought I’d write my own, this is my code:
if (file_exists('backupfile.sql')){
$FP = fopen ( 'backupfile.sql', 'r' );
$READ = fread ( $FP, filesize ( 'backupfile.sql') );
$READ = explode ( ";\n", $READ );
foreach ( $READ AS $RED )
{
mysql_query ( $RED );
}
echo 'Done';
}else{
echo "no file";
}
however this gives me the following error
Warning: fread() [function.fread]: Length parameter must be greater than 0
if I put an @ infront of the fread the script doesn’t error but it doesn’t perform the backup.
Well… My guess from the error message would be that
backupfile.sqlis empty. Therefore,fread()can’t read anything from it.