I have a code that runs a simple query like this
select * from tabela where coluna1 = 'valor';
Then I have a variable that brings a txt file
$filename = "C:/Programfile/arquivo.txt";
Then I make this condition below
if (file_exists($filename)) {
rename($filename,$filename.".old");
}
$file = fopen($filename,"a+");
After this I do the while of the query
while ($row = mysql_fetch_array($sql))
{
$content = $row[0];
$content .= "\r";
$content .= "\n";
$result = fputs($file,$content);
//break;
}
fclose($file);
The result of the query goes into the text file using vbs only I have a problem that when the query has no record the text file is empty and I am not getting to execute the script when the query does not return record can someone help me?
I already tried to do this and it did not work
if(filesize($filename)){
exit;
}
or in the place of exit already put return false e die()
and did not work.