为什么有个值,写入数据库不成功?
<!--#include file="conn.asp"-->
<%if session("admin")="" then
response.Write "<script language='javascript'>alert('网络超时或您还没有登陆!');window.location.href='login.asp';</script>"
response.End
else
if session("flag")>1 then
response.Write "<p align=center><font color=red>您没有此项目管理权限!</font></p>"
response.End
end if
end if%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../images/css.css" rel="stylesheet" type="text/css">
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkkk()
{
if(checkspace(document.myform.bookname.value)) {
document.myform.bookname.focus();
alert("请输入商品名称!");
return false;
}
if(checkspace(document.myform.shichangjia.value)) {
document.myform.shichangjia.focus();
alert("请输入市场价格!");
return false;
}
if(checkspace(document.myform.point.value)) {
document.myform.point.focus();
alert("请输入所需积分!");
return false;
}
}
function checkspace(checkstr) {
var str = '';
for(i = 0; i < checkstr.length; i++) {
str = str + ' ';
}
return (str == checkstr);
}
//-->
</script>
<script>
function regInput(obj, reg, inputStr)
{
var docSel = document.selection.createRange()
if (docSel.parentElement().tagName != "INPUT") return false
oSel = docSel.duplicate()
oSel.text = ""
var srcRange = obj.createTextRange()
oSel.setEndPoint("StartToStart", srcRange)
var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
return reg.test(str)
}
</script>
</head>
<body>
<form name="myform" method="post" action="SaveAward.asp?action=add" onSubmit="return checkkk()" >
<table cellpadding="3" cellspacing="1" border="0" width="100%" class="tableBorder" align=center>
<tr>
<th class="tableHeaderText" colspan=2>添加奖品</th>
</tr>
<tr>
<td width="30%" align="right" class="forumRowHighlight">奖品名称: </td>
<td width="70%" class="forumRowHighlight">
<input name="bookname" type="text" id="bookname" size="30">
</td>
</tr>
<tr>
<td align="right" class="forumRowHighlight">规 格: </td>
<td class="forumRowHighlight"> <input name="guige" type="text" id="guige" size="20">
</td>
</tr>
<tr>
<td align="right" class="forumRowHighlight">所需积分: </td>
<td class="forumRowHighlight">参考市场价
<input name="shichangjia" type="text" id="shichangjia" size="6" onKeyPress = "return regInput(this, /^\d*\.?\d{0,2}$/, String.fromCharCode(event.keyCode))"
onpaste = "return regInput(this, /^\d*\.?\d{0,2}$/, window.clipboardData.getData('Text'))"
ondrop = "return regInput(this, /^\d*\.?\d{0,2}$/, event.dataTransfer.getData('Text'))" value="0">
元 所需积分
<input name="point" type="text" id="point" size="6" onKeyPress = "return regInput(this, /^\d*\.?\d{0,2}$/, String.fromCharCode(event.keyCode))"
onpaste = "return regInput(this, /^\d*\.?\d{0,2}$/, window.clipboardData.getData('Text'))"
ondrop = "return regInput(this, /^\d*\.?\d{0,2}$/, event.dataTransfer.getData('Text'))" value="50">
</td>
</tr>
<tr>
<td rowspan="2" align="right" class="forumRowHighlight">奖品图片: </td>
<td class="forumRowHighlight"> <input name="bookpic" type="text" id="bookpic" size="30">
<input class="button" type="button" name="Submit2" value="上传小图片" onClick="window.open('../upload.asp?formname=myform&editname=bookpic&uppath=bookpic&filelx=jpg','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')">
</td>
</tr>
<tr>
<td class="forumRowHighlight"> <input name="bookpic2" type="text" id="bookpic2" size="30">
<input class="button" type="button" name="Submit2" value="上传大图片" onClick="window.open('../upload.asp?formname=myform&editname=bookpic2&uppath=bookpic&filelx=jpg','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')">
</td>
</tr>
<tr>
<td valign="top" align="right" class="forumRowHighlight">奖品说明: </td>
<td class="forumRowHighlight"> <textarea name="bookcontent" cols="46" rows="8" id="bookcontent"></textarea>
</td>
</tr>
<tr>
<td colspan="2" class="forumRowHighlight"> <div align="center">
<input name="xianshi" type="checkbox" id="xianshi" value="1">
显示(不选为隐藏)
<input class="button" type="submit" name="Submit" value="添 加">
</div></td>
</tr>
</table>
</form>
<br>
</body>
</html>
上面是一个添加奖品的源码
数据库名为表award 里面的积分数据库名字 jifen
可以添加,都可以显示,就是积分输入修改或是添加都无法写入 JIFEN 数据库里.
<!--#include file="conn.asp"-->
<%if session("admin")="" then
response.Write "<script language='javascript'>alert('网络超时或您还没有登陆!');window.location.href='login.asp';</script>"
response.End
else
if session("flag")>1 then
response.Write "<p align=center><font color=red>您没有此项目管理权限!</font></p>"
response.End
end if
end if
%>
<%
if request("bookname")="" or request("shichangjia")="" or request("point")="" then
response.Write "<script language='javascript'>alert('请用正确的方式添加或修改奖品!');history.go(-1);</script>"
response.End
end if
function HTMLEncode2(fString)
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
fString = Replace(fString, CHR(10), "<BR>")
HTMLEncode2 = fString
end function
dim bookdate,dazhe
'dazhe=round(request("huiyuanjia")/request("shichangjia"),2)
'if request("bookdateyear")<>"" then
'bookdate=trim(request("bookdateyear"))&"年"&trim(request("bookdatemonth"))&"月"
'else
'bookdate=""
'end if
dim action,bookid
bookid=request.QueryString("id")
action=request.QueryString("action")
select case action
case "add"
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from award",conn,1,3
rs.AddNew
rs("bookname")=trim(request("bookname")) '商品名称
rs("guige")=trim(request("guige")) '商品规格
rs("shichangjia")=trim(request("shichangjia")) '市场价
rs("point")=trim(request("point")) '积分
rs("bookpic")=trim(request("bookpic")) '小图片地址
rs("bookpic2")=trim(request("bookpic2")) '大图片地址
rs("bookcontent")=htmlencode2(trim(request("bookcontent"))) '简介
rs("adddate")=now() '加入日期
if request("xianshi")=1 then '推荐
rs("xianshi")=1
else
rs("xianshi")=0
end if
rs.Update
rs.Close
set rs=nothing
response.Write "<script language=javascript>alert('添加成功!');window.location.href='AddAward.asp';</script>"
response.End
case "edit"
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from award where bookid="&bookid,conn,1,3
rs("bookname")=trim(request("bookname")) '商品名称
rs("guige")=trim(request("guige")) '商品规格
rs("shichangjia")=trim(request("shichangjia")) '市场价
rs("point")=trim(request("point")) '积分
rs("bookpic")=trim(request("bookpic")) '小图片地址
rs("bookpic2")=trim(request("bookpic2")) '大图片地址
rs("bookcontent")=htmlencode2(trim(request("bookcontent"))) '简介
'rs("adddate")="bookdate" '加入日期
if request("xianshi")=1 then '推荐
rs("xianshi")=1
else
rs("xianshi")=0
end if
rs.Update
rs.Close
set rs=nothing
response.Write "<script language=javascript>alert('修改成功!');window.location.href='ManageAward.asp';</script>"
response.End
end select
%>
[ 本帖最后由 故事人生 于 2010-4-27 11:25 编辑 ]