[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);
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
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
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
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.
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