急救!求教一SQL语句的错误!!!急救!急救!急救!急救!

net86 2008-05-31 08:34:16
rt 代码如下:
[code=asp]
sql="update mtv_Photo set panelcolor= '"&panelColor&"',panelalpha='"&panelAlpha&"',fontcolor='"&fontColor&"',fontsize="&fontSize&",frameid="&frameID&",effectid="&effectID&",imagenum="&imageNum&",song='"&song1&"',s_images='"&s_images&"' where id=" & id & " and userid=" & user_id
conn.execute(sql)
end if
imgUrl1=replace(imgUrl,"mtvPhoto_temp","mtvPhoto_pic")
sql="insert into mtv_img_list (userid,imgpath,i_text,types,mtv_id,imgsize) values("&user_id&",'"&imgUrl1&"','"&imgInf&"',"&imgEffect&","&id&","&imgSize&")"
conn.execute(sql)
[/code]

以上是SQL语句,请教各位大虾,看有什么错误!数据库是Access的!先谢哈!
...全文
111 点赞 收藏 10
写回复
10 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
jhwcd 2008-05-31
最后你提的那个问题,我大致看了一下。
MusicDateArea=request("MusicDateArea")这句获得值是否为空?
如果为空,那么下面的语句肯定会出现数组下标越界的错误。
mode1=replace(MusicDateArea(1),"mode=","")
好好的检查一下你的程序。

回复
xie_yanke 2008-05-31
下标越界,不是语句的事儿,是数据是事儿.
回复
jhwcd 2008-05-31
'userid字段是字符类型吧,如果是就改成下面这样试试。
sql="update mtv_Photo set panelcolor= '"&panelColor&"',panelalpha='"&panelAlpha&"',fontcolor='"&fontColor&"',fontsize="&fontSize&",frameid="&frameID&",effectid="&effectID&",imagenum="&imageNum&",song='"&song1&"',s_images='"&s_images&"' where id="&id&" and userid='" &user_id&"'"

sql="insert into mtv_img_list (userid,imgpath,i_text,types,mtv_id,imgsize) values('"&user_id&"','"&imgUrl1&"','"&imgInf&"',"&imgEffect&","&id&","&imgSize&")"
回复
net86 2008-05-31
up 急救!!!
回复
晕死,你这个错误,与SQL语句有什么关系啊

你这个错误是因为你的数组里是空数据
或者只有一个数据
你使用MusicDateArea(1)他当然要下标越界了

你应该理解数组吧
使用这些东西最好判断数组长度
回复
net86 2008-05-31
贴全部吧

<%
'在这里要判断是否登录

user_id=1
user_name="test"

dim action,id,mode1,panelcolor,panelalpha,fontcolor,fontsize,frameid,effectid,imagenum,song,imgurl,imginf,imgdid,imgeffect
dim MusicDateArea,ImgDateArea,imgSize,imgUrl1,rs,sql,i,s_images


MusicDateArea=request("MusicDateArea")
ImgDateArea=request("ImgDateArea")

MusicDateArea=split(MusicDateArea,"&")

mode1=replace(MusicDateArea(1),"mode=","")

id = request("id")
if id=0 then'================
if mode1="create" then
panelColor=replace(MusicDateArea(4),"panelColor=","")
panelAlpha=replace(MusicDateArea(5),"panelAlpha=","")
fontColor=replace(MusicDateArea(6),"fontColor=","")
fontSize=replace(MusicDateArea(7),"fontSize=","")
song=replace(MusicDateArea(8),"song=","")
frameID=replace(MusicDateArea(12),"frameID=","")
effectID=replace(MusicDateArea(13),"effectID=","")

ImgDateArea=split(ImgDateArea,"|")
imageNum=ubound(ImgDateArea)
redim pic_info(imageNum-1)

set rs=server.createobject("adodb.recordset")

for i = 0 to imageNum-1
pic_info(i)=split(ImgDateArea(i),"&")
imgUrl=replace(pic_info(i)(1),"imgUrl=","")
imgInf=replace(pic_info(i)(2),"imgInf=","")
imgDid=replace(pic_info(i)(3),"imgDid=","")
imgEffect=replace(pic_info(i)(4),"imgEffect=","")
imgSize=replace(pic_info(i)(5),"imgSize=","")
if i=0 then
s_images=replace(imgUrl,"mtvPhoto_temp","mtvPhoto_pic")
song1=replace(song,"mtvPhoto_temp","mtv_Mp3")
sql="insert into mtv_Photo (userid,username,panelcolor,panelalpha,fontcolor,fontsize,frameid,effectid,imagenum,song,s_images,addtime) values("&user_id&",'"&user_name&"','"&panelColor&"',"&panelAlpha&",'"&fontColor&"',"&fontSize&","&frameID&","&effectID&","&imageNum&",'"&song1&"','"&s_images&"',getdate())"
conn.execute(sql)
'打开读取插入的ID
sql="select top 1 id from mtv_Photo order by id desc"
rs.open sql,conn,1,1
id=rs("id")
rs.close
set rs=nothing
end if
imgUrl1=replace(imgUrl,"mtvPhoto_temp","mtvPhoto_pic")
sql="insert into mtv_img_list (userid,imgpath,i_text,types,mtv_id,imgsize) values("&user_id&",'"&imgUrl1&"','"&imgInf&"',"&imgEffect&","&id&","&imgSize&")"
conn.execute(sql)
'将图片转出临时文件夹
move_pic imgUrl,imgUrl1

if instr(song1,"mtv_Mp3")>0 then
move_mp3 song,song1
end if
next

response.redirect "mtv_show_pic.asp?a=saveimg&id=" & id
else
openmsg "你能告诉我打开这个页面准备干什么吗?"
end if
else'================

if mode1="create" then
panelColor=replace(MusicDateArea(4),"panelColor=","")
panelAlpha=replace(MusicDateArea(5),"panelAlpha=","")
fontColor=replace(MusicDateArea(6),"fontColor=","")
fontSize=replace(MusicDateArea(7),"fontSize=","")
song=replace(MusicDateArea(8),"song=","")
frameID=replace(MusicDateArea(12),"frameID=","")
effectID=replace(MusicDateArea(13),"effectID=","")

ImgDateArea=split(ImgDateArea,"|")
imageNum=ubound(ImgDateArea)
redim pic_info(imageNum-1)

set rs=server.createobject("adodb.recordset")
'先删除以前的数据
conn.execute("delete from mtv_img_list where mtv_id=" & id & " and userid=" & user_id)

for i = 0 to imageNum-1
pic_info(i)=split(ImgDateArea(i),"&")
imgUrl=replace(pic_info(i)(1),"imgUrl=","")
imgInf=replace(pic_info(i)(2),"imgInf=","")
imgDid=replace(pic_info(i)(3),"imgDid=","")
imgEffect=replace(pic_info(i)(4),"imgEffect=","")
imgSize=replace(pic_info(i)(5),"imgSize=","")
if i=0 then
s_images=replace(imgUrl,"mtvPhoto_temp","mtvPhoto_pic")
song1=replace(song,"mtvPhoto_temp","mtv_Mp3")
sql="update mtv_Photo set panelcolor= '"&panelColor&"',panelalpha='"&panelAlpha&"',fontcolor='"&fontColor&"',fontsize="&fontSize&",frameid="&frameID&",effectid="&effectID&",imagenum="&imageNum&",song='"&song1&"',s_images='"&s_images&"' where id=" & id & " and userid=" & user_id
conn.execute(sql)
end if
imgUrl1=replace(imgUrl,"mtvPhoto_temp","mtvPhoto_pic")
sql="insert into mtv_img_list (userid,imgpath,i_text,types,mtv_id,imgsize) values("&user_id&",'"&imgUrl1&"','"&imgInf&"',"&imgEffect&","&id&","&imgSize&")"
conn.execute(sql)
'将图片转出临时文件夹
move_pic imgUrl,imgUrl1
if instr(song1,"mtv_Mp3")>0 then
move_mp3 song,song1
end if
next

response.redirect "mtv_show_pic.asp?a=saveimg&id=" & id
else
openmsg "你能告诉我打开这个页面准备干什么吗?"
end if

end if

function move_pic(url,url1)
dim fso,f2
Set fso = CreateObject("Scripting.FileSystemObject")
url1=replace(url1,weburl & "/","")
url=replace(url,weburl & "/","")
'CreateDir(Server.mappath(url1))
if fso.FileExists(server.MapPath(url)) then
Set f2 = fso.GetFile(Server.mappath(url))
f2.Move(Server.mappath(url1))
set f2=nothing
end if
set fso=nothing
end function

function move_mp3(url,url1)
dim fso,f2
if url1="" then
exit function
end if
Set fso = CreateObject("Scripting.FileSystemObject")
url1=replace(url1,weburl & "/","")
url=replace(url,weburl & "/","")
'CreateDir(Server.mappath(url1))
if fso.FileExists(server.MapPath(url)) then
Set f2 = fso.GetFile(Server.mappath(url))
f2.Move(Server.mappath(url1))
set f2=nothing
end if
set fso=nothing
end function
%>


错误提示:

Microsoft VBScript 运行时错误 错误 '800a0009'

下标越界: '[number: 1]'

save_Photo.asp,行 19

19行是
mode1=replace(MusicDateArea(1),"mode=","")

看不出有什么错误,哪位大虾,帮帮俺!!!
回复
什么都没有就让别人猜?
回复
wql238 2008-05-31
把错误信息发出来 这样看不出来问题
回复
jingxiaoping 2008-05-31
没看出来什么问题,前提是如果你的赋值都和数据表要求类型一致的话。
回复
net86 2008-05-31

sql="update mtv_Photo set panelcolor= '"&panelColor&"',panelalpha='"&panelAlpha&"',fontcolor='"&fontColor&"',fontsize="&fontSize&",frameid="&frameID&",effectid="&effectID&",imagenum="&imageNum&",song='"&song1&"',s_images='"&s_images&"' where id=" & id & " and userid=" & user_id
conn.execute(sql)
end if
imgUrl1=replace(imgUrl,"mtvPhoto_temp","mtvPhoto_pic")
sql="insert into mtv_img_list (userid,imgpath,i_text,types,mtv_id,imgsize) values("&user_id&",'"&imgUrl1&"','"&imgInf&"',"&imgEffect&","&id&","&imgSize&")"
conn.execute(sql)
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2008-05-31 08:34
社区公告
暂无公告