注册 登录
编程论坛 ASP技术论坛

刷新但是没有写入TXT文件

dukemian 发布于 2012-07-17 11:25, 421 次点击
程序代码:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
  
function readvote(counterfile)
  
dim jia,mian
  
set jia = server.CreateObject("scripting.filesystemobject")
  
set mian = jia.opentextfile(server.MapPath(counterfile),1,true)
  
  
if not mian.atendofstream then
  readvote
= clng(mian.readline)
  
else
  readvote
= 1
  
end if
  mian.close
  
end function
  
sub writevote(counterfile,counter)
  
dim jia,mian
  jia
= server.CreateObject("scripting.filesystemobject")
  mian
= jia.opentextfile(server.MapPath(counterfile),2,true)
  mian.write(counter)
  mian.close
  
end sub
  
dim vote,counter1,counter2,counter3
  application.Lock
  counter1
= readvote("star1.txt")
  counter2
= readvote("star2.txt")
  counter3
= readvote("star3.txt")
  
  
if vote = "star1" then
  counter1
= counter1 + 1
  writevote
"star1.txt" &counter1
  
  
elseif vote = "star2" then
  counter2
= counter2 + 1
  writevote
"star2.txt"&counter2
  
  
elseif vote = "star3" then
  counter3
= counter3 + 1
  writevote
"star3.txt"&counter3
  
  
end if
  application.UnLock
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.>
<html xmlns="http://www.>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>计算票数</title>
</head>

<body>
<P><img src="star0.jpg"  /></P>
<table>
<tr>
    <td><a href="vote.asp"?vote="star1"><img src="star1.jpg" width="240" height="320" /></a></td>
    <td><a href="vote.asp"?vote="star2"><img src="star2.jpg" width="240" height="320" /></a></td>
    <td><a href="vote.asp"?vote="star3"><img src="star3.jpg" width="240" height="320" /></a></td>
</tr>
<tr>
     <td>蔡依林的票数为:<%=counter1%></td>
     <td>杰西卡的票数为:<%=counter2%></td>
     <td>斯嘉丽的票数为:<%=counter3%></td>
</tr>
</table>

</body>
</html>



代码是这个,但是运行刷新的时候发现不管怎么点击图片,但是图片下面的累计没有增加,回到根目录去查询,发现没有写入文本,想来这里请教一下各位大大~~现在这里表示感谢啦~

只有本站会员才能查看附件,请 登录

这个是运行起来的照片,初学者求调教。。。
3 回复
#2
aspic2012-07-17 14:47
没有写入估计是权限的问题
#3
netlin2012-07-19 09:16
检查一下,你的TXT文件所在文件夹的目录权限和这个个文件的权限,
最好把它们的权限都设为Everyone有"完全控制"权。

#4
dukemian2012-07-21 23:30
我已经解决了~但还是谢谢各位的帮助~
1