 |
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

August 14th, 2003, 01:40 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
You're welcome.
Feel free to post questions regarding specific topics here again. It's easier to explain small steps than to write the entire application for you. Besides, you'd miss all the learning fun ;)
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|

August 15th, 2003, 07:19 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Imar,
Me again!
I've decided to alter my coding from what I originally went with to some I under stand a little more! However, I am getting a permission denied error where I've written:
Set objOpenFile = objFSO.CreateTextFile(strPath, True)
Here is the whole of the code block:
<% const ForReading = 1
Dim objOpenFile, objFSO, strPath, iCount
strPath = request.servervariables("PATH_INFO")
strPath = strPath & ".txt"
strPath = Server.MapPath(strPath)
set objFSO = server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strPath) Then
Set objOpenFile = objFSO.OpenTextFile(strPath, ForReading)
iCount = Cint(objOpenFile.ReadLine) + 1
objOpenFile.Close
Else
iCount = 1
End if
Set objOpenFile = objFSO.CreateTextFile(strPath, True)
objOpenFile.WriteLine(iCount)
objOpenFile.Close
Set objOpenFile = nothing
Set objFSO = nothing
response.Redirect(request.QueryString("url"))%>
I've disabled NAV script blocking, and the IUSR_MachineName account has sufficient rights so I'm not sure why I'm getting a denial.
thanks in advance
Adam
|

August 15th, 2003, 07:26 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Adam,
I think this is caused by the fact that you try to create the file when it already exists:
Code:
If objFSO.FileExists(strPath) Then
Set objOpenFile = objFSO.OpenTextFile(strPath, ForReading)
iCount = Cint(objOpenFile.ReadLine) + 1
objOpenFile.Close
Else
iCount = 1
End if
Set objOpenFile = objFSO.CreateTextFile(strPath, True)
See? Even if the file exists, you try to create it anyway by using CreateTextFile. You'll need to use OpenTextFile instead, just as you did with the part where you read the hit counter (the If block).
Take a look here to see what Google knows about this method.
HtH
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|

August 15th, 2003, 09:31 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Imar,
I use the CreateTextFile with overwrite set to True so even if the file already existed it will be overwritten with a new one. ( I did try using the OpenTextFile too but to no avail)
thanks
Adam
|

August 15th, 2003, 10:31 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Right, I missed that.
Other things to check:
1. Is your website running Out Of Process under IIS 4/5?? If that's the case, it's actually running under the IWAM account so you'll need to give that account rights as well.
2. Are you sure you are using Anonymous Access? If you are using Integrated Security, the website runs under _your_ account silently, so that account needs access to.
3. What rights did you give to the IUSR account? Did you give it rights to the file, or at least Change permissions of the the folder(s) they reside in?? (You may want to create a users group called WebserverUsers, or something similar; add yourself, the Administrator account, IUSR, IWAM and ASPNET to them and give the group just enough rights to do their thing.
4. Do you have a FAT disk available? I always leave at least one (almost empty) partition of my system to FAT. This way I can check stuff and see if it is a permissions issue. If it works on FAT, it's most likely a permissions problem.
If all this doesn't work, please post the entire code for this page and I'll try to run it here and see what happens.
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|

August 15th, 2003, 11:18 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Imar
Finally, finally I have managed to do it - it wasn't the code it was the folder permissions on the folder which I had supposedly set but hadn't - whoops - sorry about that but thanks very much for all your help anyway!
Regards
Adam
|
Similar Threads
|
Thread |
Thread Starter |
Forum |
Replies |
Last Post |
Looping with a counter? |
salhabb |
XSLT |
0 |
October 4th, 2005 05:09 AM |
Hit Counter Help! |
NeilS21 |
Classic ASP Databases |
4 |
April 29th, 2005 06:59 AM |
counter keeps reseting |
FlashMan |
Classic ASP Professional |
7 |
September 30th, 2004 12:56 PM |
Counter |
tp194 |
Javascript |
1 |
September 2nd, 2004 08:02 AM |
|
 |