-1
//Arquivo txt
$arquivo = "email.txt";
//abrir arquivo txt
$arq = fopen($arquivo,"w");
//faz consulta no banco de dados
$result = mysql_query("SELECT * FROM usuarios");
$cabecalho = "Emails extraidos\n";
fwrite($arq, $cabecalho);
while($escrever = mysql_fetch_array($result)){
$conteudo = $escrever ['email'];
//escreve no arquivo txt
fwrite($arq,$conteudo);
}
//fecha o arquivo
fclose($arq);
Where you connect to your database?
– Thiago Drulla
$dsn = "mysql:dbname=blog;host=127.0.0.1"; $dbuser = "root"; $dbpass = ""; Try{ $Pdo = new PDO($dsn, $dbuser, $dbpass); }catch(Pdoexception $e){ echo "Connection failed: ". $e->getMessage(); }
– Carlos Henrique
tried with
mysli_query
?– Pedro Augusto
the function
mysql
already deprecated, from a look at the answers of this other question, can help you: https://stackoverflow.com/questions/25644318/deprecated-mysql-query– Thiago Drulla
Possible duplicate of Export sql server query result to txt file on apache server automatically
– WMomesso
with mysqli_query ERROR: Warning: mysqli_query() expects at least 2 Parameters, 1 Given in D: wamp www pagina lan page config.php on line 24
– Carlos Henrique
how are you utilizing the
wamp
it is likely that you are using the versionPHP7.1
in which functionsmysql
were discontinued: here is another user with the same problem : https://answall.com/questions/173037/como-resolver-o-erro-call-to-undefined-function-mysql-connect– Thiago Drulla
I decided here guys thank you all for your help.
– Carlos Henrique
Possible duplicate of Uncaught Error: Call to Undefined Function mysql_query()
– Woss