strago Posted February 25, 2010 Share Posted February 25, 2010 What's the code to translate $insertCount=0; foreach($results[1] as $content) $insert = mysql_query("INSERT INTO `table` (`name`) VALUES ('$content')"); { if($insert){$insertCount++;} } into puting it in a text file? I try $insertCount=0; foreach($results[1] as $curEmail) define("DATABASE_FILE","/public_html/file.txt"); $databaseEntry = "$content\r\n\n"; { $databaseFile = fopen(DATABASE_FILE,"a"); } fwrite($databaseFile,$databaseEntry); fclose($databaseFile); { if($insert){$insertCount++;} } and it does put the content in the file....over and over and over and over..... I can't figure out where $insert goes. I think the counting is messing it all up. Link to comment https://forums.phpfreaks.com/topic/193292-data-in-text-file-instead-of-mysql-database/ Share on other sites More sharing options...
teamatomic Posted February 25, 2010 Share Posted February 25, 2010 $file='/path/to/public_html/file.txt'; foreach($results[1] as $curEmail) { file_put_contents($file, $curEmail, FILE_APPEND | LOCK_EX); } HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/193292-data-in-text-file-instead-of-mysql-database/#findComment-1017804 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.