|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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'> </td>") act.WriteLine("<td align='middle' nowrap class='bodyCopy'> </td>") act.WriteLine("<td align='middle' class='bodyCopy'> </td>") act.WriteLine("<td align='middle' class='bodyCopy'> </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'> <a href='../word/" & rs("ID") & ".htm' target='_blank'>" & rs("KPUser") & ".doc</a><br>" response.write "<img src='../images/printer.gif'> <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 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
No joy unfortunately and anyway on the online server its in sub folders why would it make a difference anyway?
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Server.mappath issue |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|