Solved

fname.Writeline code Help needed in ASP

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

776 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