PDA

Click to See Complete Forum and Search --> : [RESOLVED] Help writing data correctly to a text file


tony007
May 17th, 2006, 11:28 AM
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





$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>";

$string = "http://localhost/song=\"{$row['songid']}\"";
fwrite($handle,$string);
}
//fwrite($handle,"</player>");
fclose ($handle);

kfcSmitty
May 17th, 2006, 11:42 AM
$string = "http://localhost/song=" . {$row['songid']};


I'm pretty sure thatll do it

tony007
May 17th, 2006, 11:51 AM
$string = "http://localhost/song=" . {$row['songid']};


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

kfcSmitty
May 17th, 2006, 12:08 PM
$string = "http://localhost/song=" . $row['songid'] . "\n";
fwrite($handle,$string);


That should put it on the next line

HTH

Pino
May 17th, 2006, 12:08 PM
$string = "http://localhost/song=" . $row['songid'] ."\n";


Tried that? Should put them on differant line.

kfcSmitty
May 17th, 2006, 03:14 PM
Psst - I see you're on the forums atm. So if your question is solved, please mark the thread as such :)


Thanks,
Smitty