The purpose is to extract data from the base and save to txt file ... The script works correctly when I enter only $ log (name) on the line
if (!fwrite($savelog, $log))
When attempting to add $log2 (numero)
if (!fwrite($savelog, $log, $log2))
Accuse error
(Warning: fwrite () expects parameter 3 to be long, string given in)
What is the solution to storing the two data in txt with their proper formatting (str_pad)
?
<?php
include "conexao.php";
$querymail = mysql_query("select nome,numero from listagem");
fopen("listar.txt", "w+");
while($data = mysql_fetch_array($querymail)) {
$log = str_pad($data[nome], 30, " ", STR_PAD_RIGHT);
$log2 = str_pad($data[numero], 30, "0", STR_PAD_RIGHT);
if (!$savelog = fopen('listar.txt', "a"))
{ exit; }
if (!fwrite($savelog, $log, $log2))
{ exit; fclose($savelog); }
}
?>
<a href="listar.txt">Download</a>