|
-
May 17th, 2006, 11:28 AM
#1
Thread Starter
Frenzied Member
[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);
-
May 17th, 2006, 11:42 AM
#2
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
-
May 17th, 2006, 11:51 AM
#3
Thread Starter
Frenzied Member
Re: Help writing data correctly to a text file
 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
-
May 17th, 2006, 12:08 PM
#4
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
-
May 17th, 2006, 12:08 PM
#5
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.
-
May 17th, 2006, 03:14 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|