Results 1 to 6 of 6

Thread: [RESOLVED] Help writing data correctly to a text file

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Resolved [RESOLVED] Help writing data correctly to a text file

    Hi all. I am using the following script and it writes the song url incorectly .It writes like this :

    http://localhost/song="3040"http://localhost/song="3041"

    I want it to write each song url in one line and no " " around the songid. I be happy if some one help me fix this error.Thanks


    expected output:


    http://localhost/song=3040
    http://localhost/song=3041





    PHP Code:
    $result mysql_query($query);

    //$textfile = time() . ".txt"; 
    $textfile time() . $_SERVER['REMOTE_ADDR'] .  ".txt"
    $handle fopen ($textfile,"w+");

    //fwrite($handle,"<player showDisplay=\"yes\" showPlaylist=\"yes\" autoStart=\"yes\">");

    while($row mysql_fetch_assoc($result))
    {
        
    //echo "<br>path : {$row['filename']} <br>" .
          //   "title :{$row['title']} <br>";
      
    [B]$string "http://localhost/song=\"{$row['songid']}\""; [/B
                
    fwrite($handle,$string); 
    }
    //fwrite($handle,"</player>"); 
      
    fclose ($handle); 

  2. #2
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Help writing data correctly to a text file

    PHP Code:
    [B]$string "http://localhost/song=" . {$row['songid']}; [/B
    I'm pretty sure thatll do it

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: Help writing data correctly to a text file

    Quote Originally Posted by kfcSmitty
    PHP Code:
    [B]$string "http://localhost/song=" . {$row['songid']}; [/B
    I'm pretty sure thatll do it
    Thank u for u reply. I get this error :


    Parse error: syntax error, unexpected '{' in textfile.php on line 55

    and like 55 points to exact same line that u gave me !!

    I removed both { } and now it gives me no error and removed the "" but still the urls are ane after another!! I want them one in each line.Thanks

  4. #4
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Help writing data correctly to a text file

    Code:
    $string = "http://localhost/song=" . $row['songid'] . "\n"; 
    fwrite($handle,$string);
    That should put it on the next line

    HTH

  5. #5
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Help writing data correctly to a text file

    PHP Code:
    $string "http://localhost/song=" $row['songid'] ."\n"
    Tried that? Should put them on differant line.

  6. #6
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Help writing data correctly to a text file

    Psst - I see you're on the forums atm. So if your question is solved, please mark the thread as such


    Thanks,
    Smitty

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width