1
Good morning, you guys! I have a problem in the part of reopening a file in Txt, the problem that in the first statement it opens normally, writes and closes. But further down in the script I try to reopen the file again and even doesn’t open, so little writes on it and returns the following error.
Warning: fwrite() expects Parameter 1 to be Resource, string Given in F: wamp64 www nfe functions.php on line 70 Warning: fclose() expects Parameter 1 to be Resource, string Given in F: wamp64 www nfe functions.php on line 71
Follow the Code:
$pasta = $data[0].$data[1].$data[2]."_".$data_end[0].$data_end[1].$data_end[2];
foreach($config->empresas as $cfg){
$txt = fopen("sintegra/SINTEGRA_".$pasta.".txt", "w");
fwrite($txt,
str_pad($cfg -> reg1, 2," ", STR_PAD_RIGHT).
str_pad($cfg -> cnpj, 14," ", STR_PAD_RIGHT).
str_pad($cfg -> ie, 14," ", STR_PAD_RIGHT).
str_pad($cfg -> rsocial, 35," ", STR_PAD_RIGHT).
str_pad($cfg -> municipio, 30," ", STR_PAD_RIGHT).
str_pad($cfg -> uf, 2," ", STR_PAD_RIGHT).
str_pad($cfg -> fone, 10," ", STR_PAD_RIGHT).
str_pad($data[2].$data[1].$data[0], 8, " ", STR_PAD_RIGHT).
str_pad($data_end[2].$data_end[1].$data_end[0], 8, " ", STR_PAD_RIGHT).
str_pad($cfg -> lreg, 3," ", STR_PAD_RIGHT).
"\r\n".
str_pad($cfg -> reg2, 2," ", STR_PAD_RIGHT).
str_pad($cfg -> endereco, 34," ", STR_PAD_RIGHT).
str_pad($cfg -> numero, 5,"0", STR_PAD_LEFT).
str_pad($cfg -> comp, 22," ", STR_PAD_RIGHT).
str_pad($cfg -> bairro, 15," ", STR_PAD_RIGHT).
str_pad($cfg -> cep, 8," ", STR_PAD_RIGHT).
str_pad($cfg -> responsavel, 28," ", STR_PAD_RIGHT).
str_pad($cfg -> fone, 12,"0", STR_PAD_LEFT)
);
fclose($txt);
}
//APENAS TESTE//
$g_txt = "sintegra/SINTEGRA_".$pasta.".txt";
fopen($g_txt, "a+");
fwrite($g_txt, "aqui ficara o conteudo!");
fclose($g_txt);
Thank you my friend... had not attended me to this detail... but it was of great help.
– Palmieri A. Hell
Obg friend! I wish you! D
– Sam