Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help!!!!

Status
Not open for further replies.

superman3

Programmer
May 19, 2001
7
0
0
US
Here's my code for a sample ASP guestbook I'm messing with. I doing this from a free website that lets you have server side files including .asp. I'm doing this from the site since I have Windows XP home which doesn't support PWS!!!! I have this inside the cgi_bin and the root folder is where my default page links to this page. The page comes up, I input the info, then when I submit it says "Thanks for your entry (name user used goes here)." But there is an error saying "Microsoft VBScript runtime error '800a0046' Permission denied" Says error on line 54
I have a blank guestbook.txt in the same directory(cgi_bin). O.k. here's the code:

<% @LANGUAGE = VBScript %>

<% ' Fig. 25.12 : guestbook.asp
' Demonstrating File System Objects
Option Explicit
%>

<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
&quot;
<html xmlns = &quot;
<head>
<title>GuestBook Example</title>

<style type = &quot;text/css&quot;>
hr { size: 1; color: blue }
table { text-align: center }
td { font-size: 12pt }
p { font-size: 14pt; color: blue }
.font { font-family: arial, sans-serif }
</style>
</head>
<body>
<%
Dim fileObject, textFile, guestBook, mailtoUrl

' get physical path for this ASP page and
' concatenate guestbook.txt to it
guestbook = Request.ServerVariables( &quot;APPL_PHYSICAL_PATH&quot; ) _
& &quot;guestbook.txt&quot;

' instantiate a FileSystemObject
Set fileObject = Server.CreateObject( _
&quot;Scripting.FileSystemObject&quot; )

' check if this request is after the user has posted the form
If Request( &quot;hiddenInput&quot; ) = &quot;true&quot; Then

' print a thank you
Call Response.Write( &quot;Thanks for your entry, &quot; & _
Request( &quot;username&quot; ) & &quot;!&quot; )
%>
<hr />
<%
' build the mailtoUrl
mailtoUrl = Date() & &quot; <a href = &quot; & Chr( 34 ) _
& &quot;mailto:&quot; & Request( &quot;email&quot; ) & Chr( 34 ) _
& &quot;>&quot; & Request( &quot;username&quot; ) & &quot;</a>: &quot;


' open the guestbook, 8 is for appending
' create the guestbook if it does not exist
Set textFile = _
fileObject.OpenTextFile( guestbook, 8, True )

' write data to guestbook.txt
Call textFile.WriteLine( &quot;<hr />&quot; & mailtoUrl & _
Request( &quot;comment&quot; ) )
Call textFile.Close()
End If
%>

<p>Please leave a message in our guestbook.</p>

<!-- write form to the client -->
<form action = &quot;guestbook.asp&quot; method = &quot;post&quot;>
<table>
<tr>
<td>Your Name: </td>
<td><input class = &quot;font&quot;
type = &quot;text&quot; size = &quot;60&quot;
name = &quot;username&quot; /></td>
</tr>

<tr>
<td>Your email address:</td>
<td><input class = &quot;font&quot;
type = &quot;text&quot; size = &quot;60&quot;
name = &quot;email&quot;
value = &quot;user@isp.com&quot; />
</td>
</tr>

<tr>
<td>Tell the world: </td>
<td><textarea name = &quot;comment&quot; rows = &quot;3&quot;
cols = &quot;50&quot;>
Replace this text with the information
you would like to post.</textarea></td>
</tr>
</table>

<input type = &quot;submit&quot; value = &quot;submit&quot; />
<input type = &quot;reset&quot; value = &quot;clear&quot; />
<input type = &quot;hidden&quot; name = &quot;hiddenInput&quot;
value = &quot;true&quot; />
</form>

<%
' check if the file exists
If fileObject.FileExists( guestBook ) = True Then


' open the guestbook, &quot;1&quot; is for reading
Set textFile = fileObject.OpenTextFile( guestbook, 1 )

' read the entries from the file and write them to
' the client.
Call Response.Write( &quot;Guestbook Entries:<br />&quot; & _
textFile.ReadAll() )
Call textFile.Close()

End If
%>

</body>

</html>

If anyone can help I'd appreciate it.
 
Hi,

Line 54 and 55 read

Set textFile = _
fileObject.OpenTextFile( guestbook, 8, True )

It should be fine if you change it to

Set textFile = fileObject.OpenTextFile( guestbook, 8, True )

Let me know if you have any more problems,
Mike
 
Firstly is would like to appologise for my previous post.

If your getting permission denied, when your trying to open a file for amending. Either the file or path is invalid ie the path could be D:\inetpub\websiteguestbook.txt
or
the file already exists and is readonly. This could be set not only on the file but also in IIS.

I hope this post is marginly more useful than my last.
Sorry again.
Mike
 
Hi

Mostly &quot;Permission Denied&quot; is if the folder on the IIS server does not have &quot;read-write&quot; permissions. Tyr setting the permissions or put the TXT file in another folder that alreeady has these permissions set.

Also it could be that you opened the file using FileSystemObject in &quot;read&quot; mode but are trying to write to it.

Hope I helped.

Regards
Satishkumar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top