Link to home
Start Free TrialLog in
Avatar of Member_2_6492660_1
Member_2_6492660_1Flag for United States of America

asked on

fname.Writeline code Help needed in ASP

IIS 6.0
ASP Classic
SQL 2008

Getting error on this line
fname.WriteLine "<li><a href=""" &URLEncode(replace(song,"M:\Music","/mp3")) & """>" & song & "</a></li>"

My code follows

<%
if request.form<>"" then
dim fs,fname
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("m:\playlist\myplaylist_"&Session.SessionID&".txt",true)
strSongs=request.form("selectItem")
arraySongs=split(strSongs,",")
response.write "<ul>"
for each song in arraySongs
   response.write "<li><a href=""" & replace(song,"M:\Music","/mp3") & """>" & song & "</a></li>" 
   
   fname.WriteLine "<li><a href=""" &URLEncode(replace(song,"M:\Music","/mp3")) & """>" & song & "</a></li>"   
   
   next
response.write "</ul>" 
fname.Close
else
response.write "You did not post any data yet<br>"
end if
set fname=nothing
set fs=nothing
%>
<input type="button" value="BACK!"onClick="history.back();">

Open in new window


I get Error HTTP 500

But it does not show the line or page information

In IIS I checked the setting and I do have them correct but I think that is only for HTML code. Not sure how to debug ASP code.

All I know is that the only thing I change in the above code was the fname.writeline code

I had this code before

<%
if request.form<>"" then
dim fs,fname
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("m:\playlist\myplaylist_"&Session.SessionID&".txt",true)
strSongs=request.form("selectItem")
arraySongs=split(strSongs,",")
response.write "<ul>"
for each song in arraySongs
   response.write "<li><a href=""" & replace(song,"M:\Music","/mp3") & """>" & song & "</a></li>" 
   
   fname.WriteLine "<li><a href=""" & replace(song,"M:\Music","/mp3") & """>" & song & "</a></li>" 
   
   next
response.write "</ul>" 
fname.Close
else
response.write "You did not post any data yet<br>"
end if
set fname=nothing
set fs=nothing
%>
<input type="button" value="BACK!"onClick="history.back();">

Open in new window


The file gets created with this output  see attachement

The output I need is in this format

myplaylist.m3u
http://www.tomsmp3.com/mp3/mp3musicalbums/10CC/Billboard%20Top%20100%20-%201975/01-Billboard%20Top%20100%20-%201975-42%20I'm%20Not%20In%20Love.mp3
http://www.tomsmp3.com/mp3/mp3musicalbums/10CC/Billboard%20Top%20100%20-%201975/01-Billboard%20Top%20100%20-%201975-42%20I'm%20Not%20In%20Love.mp3
http://www.tomsmp3.com/mp3/mp3musicalbums/10CC/Billboard%20Top%20100%20-%201975/01-Billboard%20Top%20100%20-%201975-42%20I'm%20Not%20In%20Love.mp3
http://www.tomsmp3.com/mp3/mp3musicalbums/10CC/Billboard%20Top%20100%20-%201975/01-Billboard%20Top%20100%20-%201975-42%20I'm%20Not%20In%20Love.mp3
myplaylist-382776928.txt
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you are using internet explorer, make sure you uncheck "show friendly errors" in the Settings > Advanced area.
Avatar of Member_2_6492660_1

ASKER

Scott the Line of code did not error out this time that's great.

Question what is the <li> mean?

Not sure if those are needed to be written to the file check the new output file see attached

Working on a button to point to the file now.
myplaylist-561184133.txt
It's an unordered list.  They go inside the UL tags.
<ul>
  <li><a href="%2Fmp3%5CMP3MusicAlbums%5CThe+Doors%5CL%2EA%2E+Woman%5C01%2DL%2EA%2E+Woman%2DThe+Changeling%2Emp3">M:\Music\MP3MusicAlbums\The Doors\L.A. Woman\01-L.A. Woman-The Changeling.mp3</a></li>
<li><a href="+%2Fmp3%5CMP3MusicAlbums%5CThe+Doors%5CL%2EA%2E+Woman%5C02%2DL%2EA%2E+Woman%2DLove+Her+Madly%2Emp3"> M:\Music\MP3MusicAlbums\The Doors\L.A. Woman\02-L.A. Woman-Love Her Madly.mp3</a></li>
<li><a href="+%2Fmp3%5CMP3MusicAlbums%5CThe+Doors%5CL%2EA%2E+Woman%5C03%2DL%2EA%2E+Woman%2DBeen+Down+So+Long%2Emp3"> M:\Music\MP3MusicAlbums\The Doors\L.A. Woman\03-L.A. Woman-Been Down So Long.mp3</a></li>
  </ul>

Open in new window

You end up with something like this as a very raw base
User generated imageIf you are not sending to the screen, you don't need it.  If you are, then you would style the list.  Maybe take out the bullets or make them a cool shape.  Change the spacing.

You are doing a good job getting this far, but you should really take a few hours and go through at least basic html http://www.codecademy.com/tracks/web  It will save you a lot of time in the long run.
Scott,

Great job

Will be opening another question on the button soon.

Thanks again for all your help