Ho creato questo script che sarebbe una funzione di salvataggio e in un server locale, usando wamp server, funziona ma quando vado a metterlo su dei server quando inserisco un nuovo articolo, "$id == $new", dopo averlo eseguito ci sta diversi minuti a caricare la pagina e la funzione di visualizzazione degli articoli non fa vedere niente.

Ho fatto alcuni esperimenti e ho visto che il pezzo che da problemi è il seguente:

Codice PHP:
        $opentxt fopen($txt_options'w');
        
fwrite($opentxt$options[0]."\r\n");
        
fwrite($opentxt$options[1]);
        
fclose($opentxt); 
Non capisco dove ho commesso l'errore.



Codice PHP:
$error 0

$txt_options '../'.$type_app.'options.txt';

$opentxt fopen($txt_options'r');
$options file($txt_options);
fclose($opentxt);

$options[0] = del_newline($options[0]);
$options[1] = del_newline($options[1]);

$new $options[0] + 1;

$title htmlcharacters(addslashes(htmlspecialchars(trim($_REQUEST['title']))));
$article htmlcharacters(addslashes(htmlspecialchars(trim($_REQUEST['article']))));
$id $_REQUEST['id'];

$lent strlen($title);
$lena strlen($article);

if (
$lent CHARACTERS_TITLE && $lena CHARACTERS_TEXT) {
    if (
$lent != 0) {
        if (
$lena == 0) {
            
$error 3/* lena == 0 */
        
}
    }
    else {
        if (
$lena != 0) {
            
$error 2/* lent == 0 */
        
}
        else {
            if (
$id == $new) {
                
$error 4;/* lent e lena == 0 */
            
}
            else {
                
$error 5/* cancellare */
            
}
        }
    }
}
else {
    
$error 1/* caratteri massimi */
}


if (
$error == 0) {
    
$opentxt fopen('../'.$type_app.'lang/'.$type_lang.'/titles/'.$id.'.txt''w');
    
fwrite($opentxt$title);
    
fclose($opentxt);
    
$opentxt fopen('../'.$type_app.'lang/'.$type_lang.'/articles/'.$id.'.txt''w');
    
fwrite($opentxt$article);
    
fclose($opentxt);
    if (
$id == $new) {
        
$opentxt fopen('../'.$type_app.'dates/'.$id.'.txt''w');
        
fwrite($opentxtdate("d").' '.date("M").' '.date("Y"));
        
fclose($opentxt);    

        
$options[0] = $new;
        
$opentxt fopen($txt_options'w');
        
fwrite($opentxt$options[0]."\r\n");
        
fwrite($opentxt$options[1]);
        
fclose($opentxt);
    }
    echo 
"\t"."\t"."\t".'<p align="center">'.CORRECTLY_SAVE_ART.' '.$id.'</p>'."\n";
}
elseif (
$error == 5) {
    
unlink('../'.$type_app.'lang/'.$type_lang.'/titles/'.$id.'.txt');
    
unlink('../'.$type_app.'lang/'.$type_lang.'/articles/'.$id.'.txt');
    
unlink('../'.$type_app.'dates/'.$id.'.txt');
    if(
file_exists('../'.$type_app.'uploads/'.$id.'.jpg')) {
        
unlink('../'.$type_app.'uploads/'.$id.'.jpg');
    }
    echo 
"\t"."\t"."\t".'<p align="center">'.CORRECTLY_DELETE.' '.$id.'</p>'."\n";
}
else {
    switch(
$error) {
        case 
1:
            echo 
"\t"."\t"."\t".'<p align="center">'.ERROR_MAXIMUM.' '.$id.'</p>'."\n";
        break;
        case 
2:
            echo 
"\t"."\t"."\t".'<p align="center">'.ERROR_CHARACTERS_TIT.' '.$id.'</p>'."\n";
        break;
        case 
3:
            echo 
"\t"."\t"."\t".'<p align="center">'.ERROR_CHARACTERS_ART.' '.$id.'</p>'."\n";
        break;
        case 
4:
            echo 
"\t"."\t"."\t".'<p align="center">'.ERROR_CHARACTERS_BOTH.' '.$id.'</p>'."\n";
        break;
    }