| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1201 人关注过本帖
标题:提示留言成功,但不会写进数据库,什么原因?
只看楼主 加入收藏
huiyi6802
Rank: 2
等 级:论坛游民
帖 子:21
专家分:15
注 册:2011-11-4
结帖率:100%
收藏
 问题点数:0 回复次数:8 
提示留言成功,但不会写进数据库,什么原因?
<!--#include file="conn.asp"-->
<%
'Response.Addheader "Content-Type","text/html; charset=gb2312"
Response.Charset="GB2312"
ip=request.servervariables("REMOTE_ADDR")
title=nohtml(request.form("title"))
name=nohtml(request.form("name"))
tel=nohtml(request.form("tel"))
content=nohtml(request.form("content"))
code=Get_SafeStr(request.form("code"))


Function telpd(strPassword)
    Dim regEx
    Set regEx = new RegExp
    regEx.IgnoreCase = false
    regEx.global = false
    regEx.Pattern = "(^0[0-9]{2,3}-[0-9]{7,8}$)|(^0?1[0-9]{10}$)"
    if regEx.Test(strPassword) then
        telpd = true
    else
        telpd = false
    end if
    set regEx = Nothing
End Function

function incode(fString)
if not isnull(fString) then
    fString = Replace(fString, CHR(9), "&nbsp;")
    fString = Replace(fString, CHR(10) & CHR(10), "</p><p>")
    fString = Replace(fString, CHR(10), "<br/>")
    incode = fString
end if
end function

if Code<>CStr(session("CheckCode")) then
response.write "验证码不正确"
response.end
end if

if title=""  then
response.write "留言主题不能为空"
response.end
end if
if name="" then
response.write "您的姓名不能为空"
response.end
end if

if telpd(tel)=false then
response.write "电话号码填写不正确,请重新填写!格式如:0592-5983163或13400693163"
response.end
end if

if content="" then
response.write "内容不能为空"
response.end
end if
content=incode(content)

conn.execute("insert into book(title,name,tel,content,ip) values('"&title&"','"&name&"','"&tel&"','"&content&"','"&ip&"')")
response.write "留言成功"
conn.close:set conn=nothing
response.end
%>
搜索更多相关主题的帖子: 数据库 成功 content include false 
2011-11-05 18:22
孤独冷雨
Rank: 10Rank: 10Rank: 10
来 自:安徽滁州
等 级:贵宾
威 望:23
帖 子:1247
专家分:1909
注 册:2007-6-4
收藏
得分:0 
你用update试试应该可以的!

这里有男女系列成人用品,有时间兄弟们来看一看.
51za.
2011-11-05 19:15
huiyi6802
Rank: 2
等 级:论坛游民
帖 子:21
专家分:15
注 册:2011-11-4
收藏
得分:0 
为什么要用update,不是直接插入就行吗?
2011-11-05 19:35
huiyi6802
Rank: 2
等 级:论坛游民
帖 子:21
专家分:15
注 册:2011-11-4
收藏
得分:0 
回复 2楼 孤独冷雨
update是用来修改数据的呀。
2011-11-05 19:36
孤独冷雨
Rank: 10Rank: 10Rank: 10
来 自:安徽滁州
等 级:贵宾
威 望:23
帖 子:1247
专家分:1909
注 册:2007-6-4
收藏
得分:0 
rs.addrew
*****
*****
*****
rs.update

这里有男女系列成人用品,有时间兄弟们来看一看.
51za.
2011-11-05 19:38
huiyi6802
Rank: 2
等 级:论坛游民
帖 子:21
专家分:15
注 册:2011-11-4
收藏
得分:0 
回复 5楼 孤独冷雨
conn.addnew
conn("title")=request.form("title")
conn("name")=request.form("name")
conn("tel")=request.form("tel")
conn("content")=request.form("content")
conn.update

改成以上的后,连提示留言成功都没了,同样没写进数据库。
conn.execute("insert into book(title,name,tel,content,ip) values('"&title&"','"&name&"','"&tel&"','"&content&"','"&ip&"')")
用这个提示成功,但写不进数据库
2011-11-05 20:15
huiyi6802
Rank: 2
等 级:论坛游民
帖 子:21
专家分:15
注 册:2011-11-4
收藏
得分:0 
总是还没有解决呀,高手来指点一下呀,不然又要卡住了。
2011-11-05 21:25
wangjy500
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:13
帖 子:457
专家分:2569
注 册:2010-7-11
收藏
得分:0 
conn.execute("insert into book(title,name,tel,content,ip) values('aaa','bbb','ccc','ddddd','eeee')")

改成这样看能插入不,,,?


QQ:63572063
2011-11-06 12:18
netbooting
Rank: 1
等 级:新手上路
帖 子:3
专家分:7
注 册:2011-11-9
收藏
得分:0 
回复 6楼 huiyi6802
第1步:
SQL = "insert into book(title,name,tel,content,ip) values('"&title&"','"&name&"','"&tel&"','"&content&"','"&ip&"')"
Response.write SQL
看看SQL语句有没有问题

第2步:
conn.Execute() 把后面的括号去掉

第3步:
检查数据库的数据结构有没有问题,是不是都是文本类型
2011-11-09 10:50
快速回复:提示留言成功,但不会写进数据库,什么原因?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016645 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved