Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

fname.Writeline code Help needed in ASP

Posted on 2014-04-26
5
Medium Priority
?
434 Views
Last Modified: 2014-04-26
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
0
Comment
Question by:Thomas Grassi
  • 3
  • 2
5 Comments
 
LVL 54

Accepted Solution

by:
Scott Fell,  EE MVE earned 2000 total points
ID: 40024879
Should be server.URLEncode

fname.WriteLine "<li><a href=""" &server.URLEncode(replace(song,"M:\Music","/mp3")) & """>" & song & "</a></li>"
0
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 40024885
If you are using internet explorer, make sure you uncheck "show friendly errors" in the Settings > Advanced area.
0
 
LVL 23

Author Comment

by:Thomas Grassi
ID: 40025230
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
0
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 40025245
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
listIf 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.
0
 
LVL 23

Author Closing Comment

by:Thomas Grassi
ID: 40025250
Scott,

Great job

Will be opening another question on the button soon.

Thanks again for all your help
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question