101kl Posted April 21, 2010 Share Posted April 21, 2010 Here is my current php code: <?php //-------------------------- // Login details and such //-------------------------- if(isset($_POST['submit'])) { $phase1 = fopen($localtempfile, 'w'); $stringData = stripslashes($_POST["area_text"]); fwrite($phase1, $stringData); fclose($phase1); $textarea = fopen($localtempfile,"r"); $conn = ftp_connect($host) or die("Could not connect"); ftp_login($conn,$username,$password); ftp_pasv($conn,TRUE); if (ftp_delete($conn,$file)){print'<center><h2>Saved</h2></center>';}else{print'Didnt work yo-';} ftp_fput($conn,$file,$textarea,FTP_ASCII); ftp_close($conn); } ?> <form method="post" action="<?=( $_SERVER['PHP_SELF'] )?>"> <textarea name="area_text" rows="30" cols="100" ><?=( file_get_contents('ftp://'.$username.':'.$password.'@'.$host.'/'.$file) )?></textarea><br> <input type="submit" name="submit" value="Save"> </form> My question is, why is it whenever i press the save button, it saves the document but it doubles the lines it prints. You can see an example here: http://www.pubgamer.org/images/database/editfile.php Many thanks in advance. Link to comment https://forums.phpfreaks.com/topic/199277-newline-parsing/ Share on other sites More sharing options...
andrewgauger Posted April 22, 2010 Share Posted April 22, 2010 It might be a \r\n at the end of each line, why don't you try processing the string for \r characters and removing them. Then only the \n will be saved. Link to comment https://forums.phpfreaks.com/topic/199277-newline-parsing/#findComment-1046172 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.