I have a database named teste with a table called exemplo with 2 columns (id, nome): Want a php script to select all the information in the nome column, and echo that information and place them in a txt file. What's wrong in the code? I can only see the first value and not the second.. And with an infinite loop!
$link = mysql_connect('localhost', 'root', '123');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('teste', $link);
/* Desired */
$file = fopen("myfile.txt","w");
$result = mysql_query("SELECT * FROM exemplo");
$array = mysql_fetch_array($result);
while ($array) {
echo $array['nome'];
fputs($file ,$array['nome']);
}
mysql_close($link);