Extra line in text file from php?

Discussion in 'PHP' started by dotcombot, Apr 6, 2008.

  1. #1
    I'm having an issue with a php file I'm using. It is a file to receive text from a flash application and write it to a text file. This is to display text dynamically in a separate flash application.
    The problem is when I input the text and the php writes it to the text file there is an extra line at the top of the file (as if you hit return before entering the text). I do not know if this is normal or something I've done incorrectly with the php file. It normally wouldn't be a problem but when loading the text dynamically into the second flash movie it is rendered as undefined because it cannot read through the extra return line before finding the instance variable which starts on line 2 of the text.
    Can I fix this within the php file or will I have to figure it out with the flash var?

    This is my php code:

    <?
    
    $receivedFromFlashData = $_POST['inputData']; 
     
    $myTextFileHandler = @fopen("myTextFile.txt","r+"); 
     
    $txtfileArray = @file("myTextFile.txt"); 
    
    if($myTextFileHandler){      
             
         print("txtFile is opened\n");      
         
         @file("membersDatabase.txt");      
             
         foreach($txtfileArray as $count =>$member);      
         
         $gotoLastByteOfTxTFile = @fseek($myTextFileHandler,0,SEEK_END);      
         
         $count = $count + 1;      
              
         $writeInTxtFile = @fwrite($myTextFileHandler,"\npost$count=$receivedFromFlashData");      
         if($writeInTxtFile){           
              
            
              $writeStatus = "posting text was a success";           
              
               
              print("&writeStatus=$writeStatus");           
                     
         }else{      
              $writeStatus = "writing to textfile was a big failure";      
              print("&writeStatus=$writeStatus");      
         };      
          
         @fclose($myTextFileHandler);      
         
         
         }else{      
              print("opening txtfile has failed\n");      
    }; 
    
    
    print("&receivedData=$receivedFromFlashData"); 
    
    
    ?>
    PHP:
    Can anyone help or am I going to have to start over? Please...:D
     
    dotcombot, Apr 6, 2008 IP
  2. dotcombot

    dotcombot Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Nevermind, it was the /n in the post string.

    Thanks anyway.
     
    dotcombot, Apr 6, 2008 IP