|
| |
|
|
bobby
Posts: 11394 Joined: 8/15/1969 From: Seattle WA USA Status: offline
|
array question - 2/4/2003 16:48:37
This is my first time really working with an array... and I' m confused about something... Check out the following from the email list loop I' m trying to make work... The bolded lines below are supposed to do the following: 1 > reset the variable DUnsub to nothing (added this to try and fix this problem, but it' s not working) 2 > grab a URL (request.form(" unsub" )) and a User ID (myArray(0,i)) and create a URL with a variable attached... 3 > Add that string to the end of the Body... Heres the problem... in the final email I am getting duplicate strings for the DUnsub variable (the unsubscribe link)... IOW - at the end of the email is the " unsubscribe" link for the first person on the list, then the closeX HTML code follows... but then there is a duplicate link for each and every subscriber in the list until you get to the one that belongs to that subscriber... Does that make sense? It' s like the " Next" loop is duplicating the Unsub variable each time it loops and writing the whole thing into the page over and over and over again... but each time with different User ID numbers at the end... Shouldn' t it " forget" all of those other DUnsub strings as soon as it Loops? Forgive me while i go mad for a moment... DMbody=DMbody & " <p>To unsubscribe follow this link:<br>"
DMbody=DMbody & " (click or copy > paste the URL... )"
closeX=" </p></td></tr></table></body></html>"
for i = 0 to uBound(myArray)
DUnsub = " "
DUnsub = DUnsub & request.form(" unsub" ) & " ?dmkey=" & myArray(0,i)
DMBody=DMBody & DUnsub
DMbody=DMbody & closeX
DMail = myArray(1,i)
set objMail=server.createobject(" CDONTS.newmail" )
objMail.From=" an_email@address"
objMail.To=DMail
objMail.Subject=" Test"
objMail.BodyFormat = 0
objMail.MailFormat = 0
objMail.Body=DMBody
objMail.Send
set objMail=nothing
next
response.redirect (" DMForm.asp?x=3" )
end if And here' s what the end of the email looks like (note the multiple unsubscribe links): quote:
To unsubscribe follow this link: (click or copy > paste the entire URL below into your browser) http//www.URLAddress here/page.asp?dmkey=121227 http//www.URLAddress here/page.asp?dmkey=121235 http//www.URLAddress here/page.asp?dmkey=121237 Only the last one is the proper ID # for this subscriber... the others are the first two on the list (in db)!!!
< Message edited by bobby -- 2/4/2003 2:39 PM >
_____________________________
If con is the opposite of pro, is Congress the opposite of progress?
|
|
|
|
SerenityNet
Posts: 1364 Joined: 6/12/2001 From: Allen, TX, USA Status: offline
|
RE: array question - 2/4/2003 20:41:28
This is just a question from the slow section... but why are you using a multi-dimensional array. Wouldn' t myarray(i) work?
|
|
|
|
SerenityNet
Posts: 1364 Joined: 6/12/2001 From: Allen, TX, USA Status: offline
|
RE: array question - 2/5/2003 12:12:10
Bobby, if I' ve said it once then I' ve said it a quad-zillion times, " Don' t exaggerate!" But anyway, I guess I' m a visual person. I looked at the WROX samples (where I got the multi-dimensional array phrase - wish I had thought it up) and it is all still out of focus. Spooky, Bobby, any chance you could clarify this for me. I wouldn' t mind giving these things a glance.
_____________________________
</Chaos, panic, & disorder - my work here is done.>
|
|
|
|
bobby
Posts: 11394 Joined: 8/15/1969 From: Seattle WA USA Status: offline
|
RE: array question - 2/5/2003 12:50:13
I have another question guys... Why is it that .getrows above is only grabbing the first 3 records in the DB? I removed the Where clause from the Select statement, still only grabs the first three... I added:
myArray=" "
myArray=rsMail.getrows
to try and " clear" it out each time, but it still only grabs the first three records... I also rewrote the page to use a Do While... Loop and it grabs all of the records!!! Why is getrows not working the way I think it should? _________ Andrew, The array above is calling for specific records within each row of the recordset... (0,i) would be the first column (0) of the current row (i) - where (1,i) is grabbing the second column (1) from the current row (i) Since this stuff is zero based you have to start with 0 instead of 1... That help? :edit: Oops, forgot that the recordset code wasn' t included above... here it is: dim rsMail,DMtxt,myArray
set rsMail=server.createobject(" ADODB.recordset" )
DMtxt=" Select * From tblMail"
rsMail.open DMtxt, oConn, 3,3,1
if rsMail.EOF then
rsMail.close
set rsMail=nothing
oConn.close
set oConn=nothing
response.write " <p>Error at rsMail.DMProcess</p>"
else
myArray=" "
myArray=rsMail.getrows
rsMail.close
set rsMail=nothing
oConn.close
set oConn=nothing
end if
for i = 0 to uBound(myArray)
DUnsub = " "
DUnsub = request.form(" unsub" ) & " ?dmkey=" & myArray(0,i)
DUnsub = " <a href=' " & DUnsub & " ' >" & DUnsub & " </a>"
DMail = myArray(1,i)
set objMail=server.createobject(" CDONTS.newmail" )
objMail.From=" codeslinger@bdwebservices.com"
objMail.To=DMail
objMail.Subject=" Test From DragonMail"
objMail.BodyFormat = 0
objMail.MailFormat = 0
objMail.Body=DMBody & DUnsub & closeX
' objMail.Send
response.write DMail & " <br>"
set objMail=nothing
next
< Message edited by bobby -- 2/5/2003 9:54 AM >
_____________________________
If con is the opposite of pro, is Congress the opposite of progress?
|
|
|
|
rdouglass
Posts: 9228 From: Biddeford, ME USA Status: offline
|
RE: array question - 2/5/2003 13:09:46
quote:
for i = 0 to uBound(myArray) You' re only getting 3 records ' cause you' re only grabbing 3 fields and you' re defaulting to the column numbers. So when you use uBound(myArray), you' re actually saying uBound(myArray,1). Try using: for i = 0 to uBound(myArray,2) As Spooky said, getrows is already mlti-di so we need to specify that we want to use the rownumber. Hope it helps...
|
|
|
|
bobby
Posts: 11394 Joined: 8/15/1969 From: Seattle WA USA Status: offline
|
RE: array question - 2/5/2003 13:46:58
RD, I owe you a beer next time you' re in Seattle...   Thank you! Thank you! Thank you! Thank you! Thank you! That did it! When you get a minute, could you give me a little more expanation on that? Or a link to some info... I get that ...uBound(myArray) is the same as (myArray,1) - default, right? But what is that ,1 - or more to the point, what does changing it to ,2 do? What would happen if I changed to ,3 or ,5 ? (not going to right now because I think that was the last major glitch in my code...      ) Again, this forum is well worth the fee that I send to Spooky each month! [:p]
_____________________________
If con is the opposite of pro, is Congress the opposite of progress?
|
|
|
|
SerenityNet
Posts: 1364 Joined: 6/12/2001 From: Allen, TX, USA Status: offline
|
RE: array question - 2/5/2003 14:23:51
Roger, I' m also curious to know about the ,2). My ASP book is at home and I' m (supposed to be) working. I' m not sure I can survive the suspense of waiting until I get home. Erin, ditto from me. I' ve learned a tremendous amount from this post. (Enough to suggest a solution to a gripe I have with our corporate web designers. Enough even to justify following this post while at work!
_____________________________
</Chaos, panic, & disorder - my work here is done.>
|
|
|
|
rdouglass
Posts: 9228 From: Biddeford, ME USA Status: offline
|
RE: array question - 2/5/2003 14:52:52
quote:
for i = 0 to uBound(myArray,2) The two is the dimension #' of the array. By default dimension # 1 is ' column #' , dimension #2 is ' row #' . Those are the only two I use, but I have read about 3 & 4 dimension arrays - they get VERY complicated IMO. However, 2D arrays you can treat like a spredsheet and address individual ' cells' . For instance: (* remember arrays are 0-based so the first item is 0 and not 1) myArray(1,1) represents myArray(column2,row2) myArray(3,7) represents myArray(column4,row8) Does that make sense? Now to further follow this, when I call ' uBound' on an array, we are supposed to specify which item we want to ' uBound' . VBScript assumes we' re looking at the first dimension (columns) unless we specify otherwise. So to count the number of rows in a 2D array, we need to tell uBound to use the second dimension. Hence: uBound(myArray,2) I learned lots of stuff about arrays at http://www.learnasp.com/learn/index.asp Does that help? EDIT: Cant spell!!!
< Message edited by rdouglass -- 2/5/2003 2:55 PM >
|
|
|
|
SerenityNet
Posts: 1364 Joined: 6/12/2001 From: Allen, TX, USA Status: offline
|
RE: array question - 2/5/2003 16:15:34
I think I have a slippery grasp on the array. Thank you. But Bobby, let me ask you a beginner question about your connection string. Will you translate for me the line rsMail.open DMtxt, oConn, 3,3,1 ? What are the 3,3,1 representing? PS. I saw in my WROX book last night that you could have up to 60 dimensions. That would make an interesting thread.
_____________________________
</Chaos, panic, & disorder - my work here is done.>
|
|
|
|
SerenityNet
Posts: 1364 Joined: 6/12/2001 From: Allen, TX, USA Status: offline
|
RE: array question - 2/7/2003 9:12:18
Since I' m being hosted on a shared server, isn' t there a point that I' d affect server &/or page performance (I' m assuming the stored array stays server side.)
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|