Get ready for BLACK FRIDAY shopping starting in

Forums

This topic is locked

uploading file

Posted 30 May 2002 08:14:16
1
has voted
30 May 2002 08:14:16 mark chang posted:
Could you tell me what is this?

I got it everytime when I was trying to upload a file in the forum I set up.

Form was submitted with no ENCTYPE="multipart/form-data"
Please correct the form attributes and try again.

Mark

Replies

Replied 30 May 2002 09:54:42
30 May 2002 09:54:42 Julio Taylor replied:
You need to change the for type in the code to multipart/form data, just make sure the form's code looks like this:

enctype="multipart/form-data"

i hope this helps.

--J

P.S. i killed kenny
Replied 30 May 2002 11:04:36
30 May 2002 11:04:36 mark chang replied:
Dear poolio,

Thanks a lot for your reply. I am pretty new to ultradev, could you let me know more specifically how I could correct the erro? Do I make the change on reply.asp page/ if so, where is it?

Mark
Replied 30 May 2002 11:08:29
30 May 2002 11:08:29 Julio Taylor replied:
ok,

you need to open your .asp page where your form is (e.g. reply.asp), and look at the code where the <FORM> tags are, should look like this or something similar.

<form name="form1" method="POST" action="<?php echo $MM_editAction?>" enctype="multipart/form-data">

make sure that it says "multipart/form-data" where shown, if not, just replace whatever is there with the multipart/form-data attributes.

If you can't do it, just post the code for your form in here and i'll have a look,

i hope this helps.

--J

P.S. i killed kenny
Replied 30 May 2002 11:14:55
30 May 2002 11:14:55 mark chang replied:
Hi, poolio:

I did what you told, that enctype problem is gone. But I got a new one as below shown:

"Microsoft VBScript 运行时错误 错误 '800a0005'

无效的过程调用或参数: 'Left'

/info/macro_home.asp, 行215"


Anyway, I post the source code for the whole reply.asp page for your reference, could you help?

-------------- source code begin here---
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/connInfo.asp" -->
<%
'*** File Upload to: uploadfiles/reply, Extensions: "", Form: [object FormElt], Redirect: ""
'*** Pure ASP File Upload -----------------------------------------------------
' Copyright 2000 (c) George Petrov
'
' Script partially based on code from Philippe Collignon
' (www.asptoday.com/articles/20000316.htm)
'
' New features from GP:
' * Fast file save with ADO 2.5 stream object
' * new wrapper functions, extra error checking
' * UltraDev Server Behavior extension
'
' Version: 1.5.0
'------------------------------------------------------------------------------
Sub BuildUploadRequest(RequestBin)
'Get the boundary
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
if PosEnd = 0 then
Response.Write "<b>Form was submitted with no ENCTYPE=""multipart/form-data""</b><br>"
Response.Write "Please correct the form attributes and try again."
Response.End
end if
boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos = InstrB(1,RequestBin,boundary)
'Get all data inside the boundaries
Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--"))
'Members variable of objects are put in a dictionary object
Dim UploadControl
Set UploadControl = CreateObject("Scripting.Dictionary"
'Get an object name
Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition")
Pos = InstrB(Pos,RequestBin,getByteString("name=")
PosBeg = Pos+6
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename=")
PosBound = InstrB(PosEnd,RequestBin,boundary)
'Test if object is of file type
If PosFile<>0 AND (PosFile<PosBound) Then
'Get Filename, content-type and content of file
PosBeg = PosFile + 10
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
FileName = Mid(FileName,InStrRev(FileName,"\"+1)
'Add filename to dictionary object
UploadControl.Add "FileName", FileName
Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:")
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
'Add content-type to dictionary object
ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "ContentType",ContentType
'Get content of object
PosBeg = PosEnd+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = FileName
ValueBeg = PosBeg-1
ValueLen = PosEnd-Posbeg
Else
'Get content of object
Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
PosBeg = Pos+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
ValueBeg = 0
ValueEnd = 0
End If
'Add content to dictionary object
UploadControl.Add "Value" , Value
UploadControl.Add "ValueBeg" , ValueBeg
UploadControl.Add "ValueLen" , ValueLen
'Add dictionary object to main dictionary
UploadRequest.Add name, UploadControl
'Loop to next object
BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
Loop
End Sub

'String to byte string conversion
Function getByteString(StringStr)
For i = 1 to Len(StringStr)
char = Mid(StringStr,i,1)
getByteString = getByteString & chrB(AscB(char))
Next
End Function

'Byte string to string conversion
Function getString(StringBin)
getString =""
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,intCount,1)))
Next
End Function

Function UploadFormRequest(name)
on error resume next
if UploadRequest.Item(name) then
UploadFormRequest = UploadRequest.Item(name).Item("Value"
end if
End Function

'Process the upload
UploadQueryString = Replace(Request.QueryString,"GP_upload=true",""
if mid(UploadQueryString,1,1) = "&" then
UploadQueryString = Mid(UploadQueryString,2)
end if

GP_uploadAction = CStr(Request.ServerVariables("URL") & "?GP_upload=true"
If (Request.QueryString <> "" Then
if UploadQueryString <> "" then
GP_uploadAction = GP_uploadAction & "&" & UploadQueryString
end if
End If

If (CStr(Request.QueryString("GP_upload") <> "" Then
GP_redirectPage = ""
If (GP_redirectPage = "" Then
GP_redirectPage = CStr(Request.ServerVariables("URL")
end if

RequestBin = Request.BinaryRead(Request.TotalBytes)
Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary"
BuildUploadRequest RequestBin

GP_keys = UploadRequest.Keys
for GP_i = 0 to UploadRequest.Count - 1
GP_curKey = GP_keys(GP_i)
'Save all uploaded files
if UploadRequest.Item(GP_curKey).Item("FileName" <> "" then
GP_value = UploadRequest.Item(GP_curKey).Item("Value"
GP_valueBeg = UploadRequest.Item(GP_curKey).Item("ValueBeg"
GP_valueLen = UploadRequest.Item(GP_curKey).Item("ValueLen"

if GP_valueLen = 0 then
Response.Write "<B>An error has occured saving uploaded file!</B><br><br>"
Response.Write "Filename: " & Trim(GP_curPath) & UploadRequest.Item(GP_curKey).Item("FileName" & "<br>"
Response.Write "File does not exists or is empty.<br>"
Response.Write "Please correct and <A HREF=""javascript:history.back(1)"">try again</a>"
response.End
end if

'Create a Stream instance
Dim GP_strm1, GP_strm2
Set GP_strm1 = Server.CreateObject("ADODB.Stream"
Set GP_strm2 = Server.CreateObject("ADODB.Stream"

'Open the stream
GP_strm1.Open
GP_strm1.Type = 1 'Binary
GP_strm2.Open
GP_strm2.Type = 1 'Binary

GP_strm1.Write RequestBin
GP_strm1.Position = GP_ValueBeg
GP_strm1.CopyTo GP_strm2,GP_ValueLen

'Create and Write to a File
GP_curPath = Request.ServerVariables("PATH_INFO"
GP_curPath = Trim(Mid(GP_curPath,1,InStrRev(GP_curPath,"/") & "uploadfiles/reply"
if Mid(GP_curPath,Len(GP_curPath),1) <> "/" then
GP_curPath = GP_curPath & "/"
end if
on error resume next
GP_strm2.SaveToFile Trim(Server.mappath(GP_curPath))& "\" & UploadRequest.Item(GP_curKey).Item("FileName",2
if err then
Response.Write "<B>An error has occured saving uploaded file!</B><br><br>"
Response.Write "Filename: " & Trim(GP_curPath) & UploadRequest.Item(GP_curKey).Item("FileName" & "<br>"
Response.Write "Maybe the destination directory does not exist, or you don't have write permission.<br>"
Response.Write "Please correct and <A HREF=""javascript:history.back(1)"">try again</a>"
err.clear
response.End
end if
end if
next

'*** GP NO REDIRECT
end if
if UploadQueryString <> "" then
UploadQueryString = UploadQueryString & "&GP_upload=true"
else
UploadQueryString = "GP_upload=true"
end if

%>
<%
' *** Edit Operations: (Modified for File Upload) declare variables

MM_editAction = CStr(Request.ServerVariables("URL") 'MM_editAction = CStr(Request("URL")
If (UploadQueryString <> "" Then
MM_editAction = MM_editAction & "?" & UploadQueryString
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: (Modified for File Upload) set variables

If (CStr(UploadFormRequest("MM_insert") <> "" Then

MM_editConnection = MM_connInfo_STRING
MM_editTable = "reply_file"
MM_editRedirectUrl = "macro_home.asp"
MM_fieldsStr = "name|value|radiobutton|value|file|value|topicID|value|uploadID|value|content|value"
MM_columnsStr = "name|',none,''|mood|',none,''|filename|',none,''|ID|none,none,NULL|uploadID|',none,''|content|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"

' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(UploadFormRequest(MM_fields(i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And UploadQueryString <> "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And UploadQueryString <> "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & UploadQueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & UploadQueryString
End If
End If

End If
%>
<%
' *** Insert Record: (Modified for File Upload) construct a sql insert statement and execute it

If (CStr(UploadFormRequest("MM_insert") <> "" Then

' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),","
Delim = MM_typeArray(0)
If (Delim = "none" Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none" Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none" Then EmptyVal = ""
If (FormVal = "" Then
FormVal = EmptyVal
Else
If (AltVal <> "" Then
FormVal = AltVal
ElseIf (Delim = "'" Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''" & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End if
MM_tableValues = MM_tableValues & MM_columns(i)
MM_dbValues = MM_dbValues & FormVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & " values (" & MM_dbValues & ""

If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
<%

if(Request.QueryString ("ID" <> "" then updatereply__MMColParam = Request.QueryString ("ID"

%>
<%
Dim rsreply__MMColParam
rsreply__MMColParam = "1"
if (Request.QueryString("ID" <> "" then rsreply__MMColParam = Request.QueryString("ID"
%>
<%
set rsreply = Server.CreateObject("ADODB.Recordset"
rsreply.ActiveConnection = MM_connInfo_STRING
rsreply.Source = "SELECT * FROM post_file WHERE ID = " + Replace(rsreply__MMColParam, "'", "''" + ""
rsreply.CursorType = 0
rsreply.CursorLocation = 2
rsreply.LockType = 3
rsreply.Open()
rsreply_numRows = 0
%>
<%

set updatereply = Server.CreateObject("ADODB.Command"
updatereply.ActiveConnection = MM_connInfo_STRING
updatereply.CommandText = "UPDATE post_file SET reply=reply+1, replytime=Now () WHERE ID=" + Replace(updatereply__MMColParam, "'", "''" + ""
updatereply.CommandType = 1
updatereply.CommandTimeout = 0
updatereply.Prepared = true
updatereply.Execute()

%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="greyland.css" type="text/css">
<script language="JavaScript">
<!--

function getFileExtension(filePath) { //v1.0
fileName = ((filePath.indexOf('/') > -1) ? filePath.substring(filePath.lastIndexOf('/')+1,filePath.length) : filePath.substring(filePath.lastIndexOf('\\')+1,filePath.length));
return fileName.substring(fileName.lastIndexOf('.')+1,fileName.length);
}

function checkFileUpload(form,extensions) { //v1.0
document.MM_returnValue = true;
if (extensions && extensions != '') {
for (var i = 0; i<form.elements.length; i++) {
field = form.elements[i];
if (field.type.toUpperCase() != 'FILE') continue;
if (field.value == '') {
alert('File is required!');
document.MM_returnValue = false;field.focus();break;
}
if (extensions.toUpperCase().indexOf(getFileExtension(field.value).toUpperCase()) == -1) {
alert('This file is not allowed for uploading!');
document.MM_returnValue = false;field.focus();break;
} } }
}
//-->
</script>
</head>
<body bgcolor="#EBEBEB" text="#000000">
<form name="form1" method="POST" action="<%=MM_editAction%>" enctype="multipart/form-data">
<table width="650" border="0" cellspacing="0" cellpadding="0" align="center" height="74">
<tr>
<td class="verdana_16_bold_black" width="523">--- Post a reply in Macro-Trends
& Environment section ---</td>
<td class="verdana_11_black_normal" width="127">
<div align="center"><b>:::</b> <a href="macro_home.asp">Back Home</a></div>
</td>
</tr>
<tr>
<td colspan="2">
<hr size="1" width="100%" noshade>
<span class="verdana_11_black_normal">Dear Users:<br>
  To make sure your uploaded file won't be overwritten by other
users' uploading files in the future. </span> <span class="verdana_11_black_normal">
Please give your uploading file an unique name, it could contain your
user name or your upload ID No. </span><span class="verdana_11_black_normal"><b><font color="#FF0000"><%=(rsreply.Fields.Item("uploadID".Value)%></font></b> (e.g. <b><font color="#FF0000"><%=(rsreply.Fields.Item("uploadID".Value)%></font></b> -myPhoto.jpg). </span>
<hr size="1" width="100%" noshade>
</td>
</tr>
</table>
<table width="550" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#333333">
<tr>
<td height="19">
<table width="100%" border="0" cellspacing="1" cellpadding="4">
<tr>
<td bgcolor="#666666" width="24%" class="verdana_11_white_normal">
<div align="right"> Name: </div>
</td>
<td bgcolor="#E1E1E1" width="76%" class="verdana_11_black_normal">
<input type="text" name="name">
* (better put in your user name)</td>
</tr>
<tr>
<td bgcolor="#666666" width="24%" class="verdana_11_white_normal">
<div align="right">Topic Name: </div>
</td>
<td bgcolor="#E1E1E1" width="76%" class="verdana_11_black_normal"><b>Re:
" <%=(rsreply.Fields.Item("topicname".Value)%>" </b></td>
</tr>
<tr>
<td bgcolor="#666666" width="24%" class="verdana_11_white_normal" valign="top">
<div align="right">Your Moods: </div>
</td>
<td bgcolor="#F3F3F3" width="76%" class="verdana_11_black_normal">
<div align="right"></div>
<table width="27" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="3%">
<input type="radio" name="radiobutton" value="alien.gif">
</td>
<td width="7%"><img src="images/mood/alien.gif" width="15" height="15">
</td>
<td width="6%">
<input type="radio" name="radiobutton" value="angry2.gif">
</td>
<td width="4%"><img src="images/mood/angry2.gif" width="15" height="15"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="bandit.gif">
</td>
<td width="4%"><img src="images/mood/bandit.gif" width="13" height="13"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="biggrin.gif">
</td>
<td width="4%"><img src="images/mood/biggrin.gif" width="13" height="13"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="binoculars2.gif">
</td>
<td width="4%"><img src="images/mood/binoculars2.gif" width="15" height="15"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="boo.gif">
</td>
<td width="4%"><img src="images/mood/boo.gif" width="15" height="15"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="cool.gif">
</td>
<td width="4%"><img src="images/mood/cool.gif" width="13" height="13"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="devious.gif">
</td>
<td width="4%"><img src="images/mood/devious.gif" width="13" height="13"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="dynamite.gif">
</td>
<td width="4%"><img src="images/mood/dynamite.gif" width="15" height="15"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="eek.gif">
</td>
<td width="4%"><img src="images/mood/eek.gif" width="13" height="13"></td>
</tr>
<tr>
<td width="3%">
<input type="radio" name="radiobutton" value="frown.gif">
</td>
<td width="7%"><img src="images/mood/frown.gif" width="13" height="13"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="gift.gif">
</td>
<td width="4%"><img src="images/mood/gift.gif" width="15" height="15"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="headphones.gif">
</td>
<td width="4%"><img src="images/mood/headphones.gif" width="15" height="15"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="help.gif">
</td>
<td width="4%"><img src="images/mood/help.gif" width="16" height="16"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="hi.gif">
</td>
<td width="4%"><img src="images/mood/hi.gif" width="15" height="15"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="knocked-out.gif">
</td>
<td width="4%"><img src="images/mood/knocked-out.gif" width="13" height="13"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="mad.gif">
</td>
<td width="4%"><img src="images/mood/mad.gif" width="13" height="13"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="pirate(1).gif">
</td>
<td width="4%"><img src="images/mood/pirate(1).gif" width="13" height="13"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="no.gif">
</td>
<td width="4%"><img src="images/mood/no.gif" width="13" height="13"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="razz.gif">
</td>
<td width="4%"><img src="images/mood/razz.gif" width="15" height="15"></td>
</tr>
<tr>
<td width="3%">
<input type="radio" name="radiobutton" value="redface.gif">
</td>
<td width="7%"><img src="images/mood/redface.gif" width="13" height="13"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="rocket.gif">
</td>
<td width="4%"><img src="images/mood/rocket.gif" width="15" height="15"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="rolleyes.gif">
</td>
<td width="4%"><img src="images/mood/rolleyes.gif" width="13" height="13"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="smile.gif">
</td>
<td width="4%"><img src="images/mood/smile.gif" width="15" height="15"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="surprised.gif">
</td>
<td width="4%"><img src="images/mood/surprised.gif" width="15" height="15"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="tongue.gif">
</td>
<td width="4%"><img src="images/mood/tongue.gif" width="13" height="13"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="unhappy.gif">
</td>
<td width="4%"><img src="images/mood/unhappy.gif" width="15" height="15"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="wink.gif">
</td>
<td width="4%"><img src="images/mood/wink.gif" width="15" height="15"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="yea.gif">
</td>
<td width="4%"><img src="images/mood/yea.gif" width="15" height="15"></td>
<td width="6%">
<input type="radio" name="radiobutton" value="nerd.gif" checked>
</td>
<td width="4%"><img src="images/mood/nerd.gif" width="15" height="15"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#666666" width="24%" class="verdana_11_white_normal">
<div align="right">Upload Files: </div>
</td>
<td bgcolor="#E1E1E1" width="76%" class="verdana_11_black_normal">
<input type="file" name="file">
<input type="hidden" name="topicID" value="<%=(rsreply.Fields.Item("ID".Value)%>">
<i>
<input type="hidden" name="uploadID" value="<%=(rsreply.Fields.Item("uploadID".Value)%>">
&lt;/i&gt; &lt;i&gt;&lt;font color="#993300"&gt;(your upload ID: &lt;span class="verdana_11_black_normal"&gt;&lt;b&gt;&lt;%=(rsreply.Fields.Item("uploadID".Value)%&gt<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td bgcolor="#666666" width="24%" class="verdana_11_white_normal"&gt;
&lt;div align="right"&gt;Category: &lt;/div&gt;
&lt;/td&gt;
&lt;td bgcolor="#E1E1E1" width="76%" class="verdana_11_black_normal"&gt;&lt;b&gt;&lt;%=(rsreply.Fields.Item("category".Value)%&gt;&lt;/b&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td bgcolor="#666666" width="24%" class="verdana_11_white_normal" valign="top"&gt;
&lt;div align="right"&gt;Your comments:&lt;br&gt;
&lt;br&gt;
&lt;i&gt;&lt;font color="#FFC58A"&gt;(your comments of your topic or explanation
of your uploading files) &lt;/font&gt;&lt;/i&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td bgcolor="#E1E1E1" width="76%" class="verdana_11_black_normal"&gt;
&lt;textarea name="content" rows="5" cols="45"&gt;&lt;/textarea&gt;
* &lt;/td&gt;
&lt;/tr&gt;
&lt;tr bgcolor="#FFFFFF"&gt;
&lt;td width="24%"&gt;&nbsp;&lt;/td&gt;
&lt;td width="76%"&gt;
&lt;input type="submit" name="Submit" value="Submit"&gt;
&lt;input type="reset" name="Submit2" value="Reset"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;input type="hidden" name="MM_insert" value="true"&gt;
&lt;/form&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;%
rsreply.Close()
%&gt;

-----------------end of source code-----


thanks a lot poolio.
Replied 30 May 2002 11:18:11
30 May 2002 11:18:11 mark chang replied:
Sorry Poolio,

I guess I got the wrong source code for you, it should be the another page called macro_home.asp, code as below shown:

---------------------sour code begin -----


&lt;%@LANGUAGE="VBSCRIPT"%&gt;
&lt;!--#include file="Connections/connInfo.asp" --&gt;
&lt;%
set rsmacrohome = Server.CreateObject("ADODB.Recordset"
rsmacrohome.ActiveConnection = MM_connInfo_STRING
rsmacrohome.Source = "SELECT * FROM post_file ORDER BY createtime DESC"
rsmacrohome.CursorType = 0
rsmacrohome.CursorLocation = 2
rsmacrohome.LockType = 3
rsmacrohome.Open()
rsmacrohome_numRows = 0
%&gt;
&lt;%
Dim rsuser__MMColParam
rsuser__MMColParam = "1"
if (Session("MM_Username" &lt;&gt; "" then rsuser__MMColParam = Session("MM_Username"
%&gt;
&lt;%
set rsuser = Server.CreateObject("ADODB.Recordset"
rsuser.ActiveConnection = MM_connInfo_STRING
rsuser.Source = "SELECT * FROM user WHERE name = '" + Replace(rsuser__MMColParam, "'", "''" + "'"
rsuser.CursorType = 0
rsuser.CursorLocation = 2
rsuser.LockType = 3
rsuser.Open()
rsuser_numRows = 0
%&gt;
&lt;%
Dim Repeat1__numRows
Repeat1__numRows = 15
Dim Repeat1__index
Repeat1__index = 0
rsmacrohome_numRows = rsmacrohome_numRows + Repeat1__numRows
%&gt;
&lt;%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

' set the record count
rsmacrohome_total = rsmacrohome.RecordCount

' set the number of rows displayed on this page
If (rsmacrohome_numRows &lt; 0) Then
rsmacrohome_numRows = rsmacrohome_total
Elseif (rsmacrohome_numRows = 0) Then
rsmacrohome_numRows = 1
End If

' set the first and last displayed record
rsmacrohome_first = 1
rsmacrohome_last = rsmacrohome_first + rsmacrohome_numRows - 1

' if we have the correct record count, check the other stats
If (rsmacrohome_total &lt;&gt; -1) Then
If (rsmacrohome_first &gt; rsmacrohome_total) Then rsmacrohome_first = rsmacrohome_total
If (rsmacrohome_last &gt; rsmacrohome_total) Then rsmacrohome_last = rsmacrohome_total
If (rsmacrohome_numRows &gt; rsmacrohome_total) Then rsmacrohome_numRows = rsmacrohome_total
End If
%&gt;
&lt;%
' *** Move To Record and Go To Record: declare variables

Set MM_rs = rsmacrohome
MM_rsCount = rsmacrohome_total
MM_size = rsmacrohome_numRows
MM_uniqueCol = ""
MM_paramName = ""
MM_offset = 0
MM_atTotal = false
MM_paramIsDefined = false
If (MM_paramName &lt;&gt; "" Then
MM_paramIsDefined = (Request.QueryString(MM_paramName) &lt;&gt; ""
End If
%&gt;
&lt;%
' *** Move To Record: handle 'index' or 'offset' parameter

if (Not MM_paramIsDefined And MM_rsCount &lt;&gt; 0) then

' use index parameter if defined, otherwise use offset parameter
r = Request.QueryString("index"
If r = "" Then r = Request.QueryString("offset"
If r &lt;&gt; "" Then MM_offset = Int(r)

' if we have a record count, check if we are past the end of the recordset
If (MM_rsCount &lt;&gt; -1) Then
If (MM_offset &gt;= MM_rsCount Or MM_offset = -1) Then ' past end or move last
If ((MM_rsCount Mod MM_size) &gt; 0) Then ' last page not a full repeat region
MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
Else
MM_offset = MM_rsCount - MM_size
End If
End If
End If

' move the cursor to the selected record
i = 0
While ((Not MM_rs.EOF) And (i &lt; MM_offset Or MM_offset = -1))
MM_rs.MoveNext
i = i + 1
Wend
If (MM_rs.EOF) Then MM_offset = i ' set MM_offset to the last possible record

End If
%&gt;
&lt;%
' *** Move To Record: if we dont know the record count, check the display range

If (MM_rsCount = -1) Then

' walk to the end of the display range for this page
i = MM_offset
While (Not MM_rs.EOF And (MM_size &lt; 0 Or i &lt; MM_offset + MM_size))
MM_rs.MoveNext
i = i + 1
Wend

' if we walked off the end of the recordset, set MM_rsCount and MM_size
If (MM_rs.EOF) Then
MM_rsCount = i
If (MM_size &lt; 0 Or MM_size &gt; MM_rsCount) Then MM_size = MM_rsCount
End If

' if we walked off the end, set the offset based on page size
If (MM_rs.EOF And Not MM_paramIsDefined) Then
If (MM_offset &gt; MM_rsCount - MM_size Or MM_offset = -1) Then
If ((MM_rsCount Mod MM_size) &gt; 0) Then
MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
Else
MM_offset = MM_rsCount - MM_size
End If
End If
End If

' reset the cursor to the beginning
If (MM_rs.CursorType &gt; 0) Then
MM_rs.MoveFirst
Else
MM_rs.Requery
End If

' move the cursor to the selected record
i = 0
While (Not MM_rs.EOF And i &lt; MM_offset)
MM_rs.MoveNext
i = i + 1
Wend
End If
%&gt;
&lt;%
' *** Move To Record: update recordset stats

' set the first and last displayed record
rsmacrohome_first = MM_offset + 1
rsmacrohome_last = MM_offset + MM_size
If (MM_rsCount &lt;&gt; -1) Then
If (rsmacrohome_first &gt; MM_rsCount) Then rsmacrohome_first = MM_rsCount
If (rsmacrohome_last &gt; MM_rsCount) Then rsmacrohome_last = MM_rsCount
End If

' set the boolean used by hide region to check if we are on the last record
MM_atTotal = (MM_rsCount &lt;&gt; -1 And MM_offset + MM_size &gt;= MM_rsCount)
%&gt;
&lt;%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName &lt;&gt; "" Then MM_removeList = MM_removeList & "&" & MM_paramName & "="
MM_keepURL="":MM_keepForm="":MM_keepBoth="":MM_keepNone=""

' add the URL parameters to the MM_keepURL string
For Each Item In Request.QueryString
NextItem = "&" & Item & "="
If (InStr(1,MM_removeList,NextItem,1) = 0) Then
MM_keepURL = MM_keepURL & NextItem & Server.URLencode(Request.QueryString(Item))
End If
Next

' add the Form variables to the MM_keepForm string
For Each Item In Request.Form
NextItem = "&" & Item & "="
If (InStr(1,MM_removeList,NextItem,1) = 0) Then
MM_keepForm = MM_keepForm & NextItem & Server.URLencode(Request.Form(Item))
End If
Next

' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
if (MM_keepBoth &lt;&gt; "" Then MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
if (MM_keepURL &lt;&gt; "" Then MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
if (MM_keepForm &lt;&gt; "" Then MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)

' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
If (firstItem &lt;&gt; "" Then
MM_joinChar = "&"
Else
MM_joinChar = ""
End If
End Function
%&gt;
&lt;%
' *** Move To Record: set the strings for the first, last, next, and previous links

MM_keepMove = MM_keepBoth
MM_moveParam = "index"

' if the page has a repeated region, remove 'offset' from the maintained parameters
If (MM_size &gt; 0) Then
MM_moveParam = "offset"
If (MM_keepMove &lt;&gt; "" Then
params = Split(MM_keepMove, "&"
MM_keepMove = ""
For i = 0 To UBound(params)
nextItem = Left(params(i), InStr(params(i),"=" - 1)
If (StrComp(nextItem,MM_moveParam,1) &lt;&gt; 0) Then
MM_keepMove = MM_keepMove & "&" & params(i)
End If
Next
If (MM_keepMove &lt;&gt; "" Then
MM_keepMove = Right(MM_keepMove, Len(MM_keepMove) - 1)
End If
End If
End If

' set the strings for the move to links
If (MM_keepMove &lt;&gt; "" Then MM_keepMove = MM_keepMove & "&"
urlStr = Request.ServerVariables("URL" & "?" & MM_keepMove & MM_moveParam & "="
MM_moveFirst = urlStr & "0"
MM_moveLast = urlStr & "-1"
MM_moveNext = urlStr & Cstr(MM_offset + MM_size)
prev = MM_offset - MM_size
If (prev &lt; 0) Then prev = 0
MM_movePrev = urlStr & Cstr(prev)
%&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=gb2312"&gt;
&lt;link rel="stylesheet" href="greyland.css" type="text/css"&gt;
&lt;/head&gt;
&lt;body bgcolor="#EBEBEB" text="#000000"&gt;
&lt;table width="750" border="0" cellspacing="0" cellpadding="0" align="center"&gt;
&lt;tr&gt;
&lt;td width="55%" class="verdana_11_black_normal"&gt;Dear &lt;b&gt;&lt;font color="#FF0000"&gt;&lt;%=(rsuser.Fields.Item("name".Value)%&gt;&lt;/font&gt;&lt;/b&gt;
:&lt;br&gt;
--- Welcome to the Info Base of The Grey Land !&lt;/td&gt;
&lt;td width="9%"&gt;
&lt;div align="right"&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td width="14%" class="verdana_11_black_normal"&gt;
&lt;div align="center"&gt;&lt;b&gt;:::&lt;/b&gt; &lt;a href="home.asp"&gt;Back Home&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td width="10%" class="verdana_11_black_normal"&gt;
&lt;div align="center"&gt;&lt;b&gt;:::&lt;/b&gt; Search&lt;/div&gt;
&lt;/td&gt;
&lt;td width="12%" class="verdana_11_black_normal"&gt;
&lt;div align="center"&gt;&lt;b&gt;:::&lt;/b&gt; &lt;a href="macro_new.asp"&gt;New Topic&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;hr noshade width="750" size="1" align="center"&gt;
&lt;br&gt;
&lt;table width="725" border="0" cellspacing="1" cellpadding="0" bgcolor="#333333" align="center" height="8"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;table width="100%" border="0" cellspacing="1" cellpadding="2" height="50" align="center"&gt;
&lt;tr bgcolor="#333333"&gt;
&lt;td width="223" class="verdana_11_white_normal"&gt;&lt;b&gt;Topic Name&lt;/b&gt;&lt;/td&gt;
&lt;td width="74" class="verdana_11_white_normal"&gt;
&lt;div align="center"&gt;&lt;b&gt;Post By&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td width="147" class="verdana_11_white_normal"&gt;
&lt;div align="center"&gt;&lt;b&gt;Category&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td width="55" class="verdana_11_white_normal"&gt;
&lt;div align="center"&gt;&lt;b&gt;Reply&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td width="44" class="verdana_11_white_normal"&gt;
&lt;div align="center"&gt;&lt;b&gt;View&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td width="149" class="verdana_11_white_normal"&gt;
&lt;div align="center"&gt;&lt;b&gt;Last Reply&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;%
While ((Repeat1__numRows &lt;&gt; 0) AND (NOT rsmacrohome.EOF))
%&gt;
&lt;% If Not rsmacrohome.EOF Or Not rsmacrohome.BOF Then %&gt;
&lt;tr bgcolor="#FFFFFF"&gt;
&lt;td width="223" class="verdana_11_black_normal"&gt;&lt;img src="images/mood/&lt;%=(rsmacrohome.Fields.Item("mood".Value)%&gt;"&gt;
: &lt;A HREF="macro_display.asp?&lt;%= MM_keepNone & MM_joinChar(MM_keepNone) & "ID=" & rsmacrohome.Fields.Item("ID".Value %&gt;"&gt;&lt;%=(rsmacrohome.Fields.Item("topicname".Value)%&gt;&lt;/A&gt;&lt;/td&gt;
&lt;td width="74" class="verdana_11_black_normal"&gt;
&lt;div align="center"&gt;&lt;%=(rsmacrohome.Fields.Item("name".Value)%&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td width="147" class="verdana_11_black_normal"&gt;
&lt;div align="center"&gt;&lt;%=(rsmacrohome.Fields.Item("category".Value)%&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td width="55" class="verdana_11_black_normal"&gt;
&lt;div align="center"&gt;&lt;%=(rsmacrohome.Fields.Item("reply".Value)%&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td width="44" class="verdana_11_black_normal"&gt;
&lt;div align="center"&gt;&lt;%=(rsmacrohome.Fields.Item("hit".Value)%&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td width="149" class="verdana_11_black_normal"&gt;
&lt;div align="center"&gt;&lt;%=(rsmacrohome.Fields.Item("replytime".Value)%&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;% End If ' end Not rsmacrohome.EOF Or NOT rsmacrohome.BOF %&gt;
&lt;%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsmacrohome.MoveNext()
Wend
%&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;br&gt;
&lt;table border="0" width="120" align="right"&gt;
&lt;tr&gt;
&lt;td width="29%" align="center"&gt;
&lt;% If MM_offset &lt;&gt; 0 Then %&gt;
&lt;a href="&lt;%=MM_moveFirst%&gt;"&gt;&lt;img src="First.gif" border=0&gt;&lt;/a&gt;
&lt;% End If ' end MM_offset &lt;&gt; 0 %&gt;
&lt;/td&gt;
&lt;td width="23%" align="center"&gt;
&lt;% If MM_offset &lt;&gt; 0 Then %&gt;
&lt;a href="&lt;%=MM_movePrev%&gt;"&gt;&lt;img src="Previous.gif" border=0&gt;&lt;/a&gt;
&lt;% End If ' end MM_offset &lt;&gt; 0 %&gt;
&lt;/td&gt;
&lt;td width="26%" align="center"&gt;
&lt;% If Not MM_atTotal Then %&gt;
&lt;a href="&lt;%=MM_moveNext%&gt;"&gt;&lt;img src="Next.gif" border=0&gt;&lt;/a&gt;
&lt;% End If ' end Not MM_atTotal %&gt;
&lt;/td&gt;
&lt;td width="22%" align="center"&gt;
&lt;% If Not MM_atTotal Then %&gt;
&lt;a href="&lt;%=MM_moveLast%&gt;"&gt;&lt;img src="Last.gif" border=0&gt;&lt;/a&gt;
&lt;% End If ' end Not MM_atTotal %&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;br&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;%
rsmacrohome.Close()
%&gt;
&lt;%
rsuser.Close()
%&gt;


--------------------- source code ends---


thanks a lot poolio! Mark

Reply to this topic