Solved

fname.Writeline code Help needed in ASP

Posted on 2014-04-26
5
404 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 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 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 52

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 52

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

932 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now