Solved

fname.Writeline code Help needed in ASP

Posted on 2014-04-26
5
399 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Scott,

Great job

Will be opening another question on the button soon.

Thanks again for all your help
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Swiper slider stops between pages 11 30
502 - Web server received an invalid response 4 32
INNER JOIN ? 8 29
Stupid git question 2 18
Lync server 2013 Backup Service Error ID 4049 ā€“ After File Share Migration
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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ā€¦

771 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

10 Experts available now in Live!

Get 1:1 Help Now