ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 20th, 2003, 09:27 PM
gspiteri gspiteri is offline
Specialise in Asp
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 19 gspiteri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Server.mappath issue

Hey all i have a problem for you all Im running Windows XP and im using the following script to create and delete a folder as well as im creating a document:

sql="SELECT * FROM KPUsers WHERE Department='"& dep &"'"
set rs=OBJdbconn.execute(sql)

Foldertodelete=server.mappath("../word")
Set fs = CreateObject("Scripting.FileSystemObject")
fs.DeleteFolder(Foldertodelete)
Set fs=nothing
'Recreate new word folder
Set fso = CreateObject("Scripting.FileSystemObject")
folder = Server.mapPath("../word")
if not fso.FolderExists(folder) then
fso.CreateFolder(folder)
end if
Set fso = Nothing

file_being_created= "../word/" & rs("ID") & ".htm"
' create a file system object
set fso = createobject("scripting.filesystemobject")
' create the wordtext file - true will overwrite any previous files
Set act = fso.CreateTextFile(server.mappath(file_being_created), true)


do while not rs.eof

act.WriteLine("<HTML><HEAD><TITLE>(1498243456 DBase info)</TITLE>")
act.WriteLine("<META http-equiv=Content-Type content='text/html; charset=us-ascii'></HEAD>")
act.WriteLine("<body bgcolor='#FFFFFF' onload=""print();"">")
act.WriteLine("<link href='../styles/c.css' rel='stylesheet' type='text/css'>")
act.WriteLine("<table valign='top' width='700' border='0' align='center' cellpadding='0' cellspacing='1' ID="Table1">")
act.WriteLine("<tr><td background='../images/line.gif'><img width='305' height='97' src='../images/logo2.gif'></td>")
act.WriteLine("</tr><tr><td class='header'>Summary Access Report - Clients</td>")
act.WriteLine("</tr><tr><td><div class='department'>Department: " & rs("department") & "</div>")
act.WriteLine("</td></tr><tr><td bgcolor='#cccccc' class='celLineBotomRight'><div class='courseName'>Course Name: " & rs2("coursename") & "</div>")
rs2.close
act.WriteLine("</td></tr><tr><td><table width='100%' border='0' cellspacing='0' cellpadding='0' ID="Table2">")
act.WriteLine("<tr><td class='celLineBotomRight' vAlign='top'><table border='0' cellpadding='1' cellspacing='1' class='smTextMagenta' ID="Table3">")
act.WriteLine("<tr><td>Username: " & rs("KPUser") & "</td></tr>")
act.WriteLine("<tr><td>Password: " & rs("KPPassword") & "</td></tr>")
act.WriteLine("<tr><td>" & rs("Email") & "</td></tr>")
act.WriteLine("<tr><td>Address: " & rs("address1") & "</td></tr>")
act.WriteLine("<tr><td>State: " & rs("State") & "</td></tr>")
act.WriteLine("<tr><td>Country: " & rs("Country") & "</td></tr>")
act.WriteLine("<tr><td>Expiry Date: " & rs("DateOut") & "</td></tr></table></td>")
act.WriteLine("<td vAlign=top><table width='100%' border='0' cellpadding='0' cellspacing='0' ID="Table4">")
temp=rs("ID")
sql="SELECT * FROM KPCourseDetails WHERE ID='"& temp &"'"
set rs1=OBJdbconn.execute(sql)
act.WriteLine("<tr><td align='left' nowrap class='celLineBotomRight'><div class='bodyCopyBold'>Lesson Name:</div>")
act.WriteLine("</td><td align='middle' class='celLineBotomRight'><div class='bodyCopyBold'>Lesson Status:</div>")
act.WriteLine("</td><td align='middle' nowrap class='celLineBotomRight'><div class='bodyCopyBold'>Last date attempted:</div>")
act.WriteLine("</td><td align='middle' class='celLineBotomRight'><div class='bodyCopyBold'>Times attempted:</div>")
while not rs1.eof
if i mod 2 then
act.WriteLine("</td></tr><tr><td align='left' nowrap class='celldotsbottom'><div class='bodyCopyBold'>" & rs1("lessonname") & "</div>")
else
act.WriteLine("</td></tr><tr><td align='left' nowrap class='bodyCopy'><div class='bodyCopyBold'>" & rs1("lessonname") & "</div>")
end if
if i mod 2 then
act.WriteLine("</td><td align='middle' nowrap class='celldotsbottom'><div class='bodyCopy'>" & rs1("lessonstatus") & "</div>")
else
act.WriteLine("</td><td align='middle' nowrap class='bodyCopy'><div class='bodyCopy'>" & rs1("lessonstatus") & "</div>")
end if
if i mod 2 then
act.WriteLine("</td><td align='middle' nowrap class='celldotsbottom'><div class='bodyCopyBold'>" & rs1("lessondate") & "</div>")
else
act.WriteLine("</td><td align='middle' nowrap class='bodyCopy'><div class='bodyCopyBold'>" & rs1("lessondate") & "</div>")
end if
if i mod 2 then
act.WriteLine("</div></td><td align='middle' class='celldotsbottom'><div class='bodyCopy'>" & rs1("timesattempted") & "</div></td></tr>")
else
act.WriteLine("</div></td><td align='middle' class='bodyCopy'><div class='bodyCopy'>" & rs1("timesattempted") & "</div></td></tr>")
end if
temp2=temp2+rs1("timesattempted")
i=i+1
rs1.movenext
wend
rs1.close
average=(temp2/i)
act.WriteLine("<tr><td align='left' valign='top' nowrap class='bodyCopy'>&nbsp;</td>")
act.WriteLine("<td align='middle' nowrap class='bodyCopy'>&nbsp;</td>")
act.WriteLine("<td align='middle' class='bodyCopy'>&nbsp;</td>")
act.WriteLine("<td align='middle' class='bodyCopy'>&nbsp;</td>")
act.WriteLine("</tr></table></td></tr></table></td></tr>")
act.WriteLine("<tr><td align='right'><table width='50%' border='0' cellpadding='1' cellspacing='0' class='summary' ID="Table5">")
act.WriteLine("<tr><td align='right' nowrap>Average of times attempted on each lesson: " & Round(average) & "</td></tr>")
act.WriteLine("<tr><td align='right' nowrap>Average Score to Date:86%</td></tr>")
act.WriteLine("<tr><td align='right' nowrap>Report created on: " & now () & "</td></tr>")
act.WriteLine("</table></td></tr></table></body></HTML>")

' close the object
act.close

' Writes the links to the newly created pages in the browser
'response.write "<img src='../images/printer.gif'>&nbsp;<a href='../word/" & rs("ID") & ".htm' target='_blank'>" & rs("KPUser") & ".doc</a><br>"
response.write "<img src='../images/printer.gif'>&nbsp;<A HREF=""javascript:winname='KP' + Math.round(Math.random() * 1024) +1;KP=window.open('../word/" & rs("ID") & ".htm', winname, 'status=no,resizable=yes,toolbar=no,scrollbars=Yes,width=800,height=600');KP.moveTo((screen.width-800)/2,(screen.height-600)/5);KP.focus()"" onMouseOver=""window.status='Disk Defragmenter ';return true"" onMouseOut=""window.status='';return true"">" & rs("KPUser") & "</A><br>"
' move to the next record
rs.movenext
loop
response.Write"<br>Click <a href='#' onclick='history.back();'>here</a> to go back"

Hope its readable guys but the main isssue is just running it locally it doesnt work it does nothing but online it works fine dont understand why any suggestions would be most helpful thanks

Reply With Quote
  #2  
Old November 20th, 2003, 10:24 PM
INF INF is offline
Standards User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 146 INF User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 4 sec
Reputation Power: 6
Please use the code button (# next to PHP) when posting code, it makes it much more readable. But like you said, it's more of an issue with it not running locally.

What is the URL you use to access your script locally? If it's something like http://localhost/sitefolder/script (in other words your site isn't in the web root folder, but a sub folder of that) then that's your problem, you'll need to do some re-configuring of your IIS setup or add a few lines to change the value of Server.MapPath when the script is local.

Reply With Quote
  #3  
Old November 20th, 2003, 10:50 PM
gspiteri gspiteri is offline
Specialise in Asp
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 19 gspiteri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
No joy unfortunately and anyway on the online server its in sub folders why would it make a difference anyway?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Server.mappath issue


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway