Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a pop up issue with code 1

Status
Not open for further replies.

Baldwin238

Technical User
Feb 23, 2005
68
0
0
US
I use Snitz Forums on my site and I am having a problem with one of the"mods" I am adding in. No one over at their support forum like to answer my questions I post so I coming to my second home in hopes of finding an answer.

The problem is in somewhere. The code is inserted as an include into the footer of my forum so that it shows up on every forum page no matter what. The code is supposed to display a pop up "alert" message to the user for whatever amount I set it to in my admin section.

In the admin section, you can set it to alert 1-10 times. However, no matter what you set it for, it pops up endlessly every time you enter a new page or hit refresh (you could imagine how annoying that is). But I do need it so I can alert my members of an important announcement or change in schedule, etc.

I'm hoping someone can see a flaw in the code or in the logic of the code and possibly provide a fix or an idea for me! ANy help would be greatly appreciated. Thank you kindly - Jeff B.

ps. I have a feeling the error of constantly popping up is somewhere around or in these lines:

Code:
				'We need to check now if the member has already or not be alerted
				AlertShow = False
				If not (rs2.EOF or rs2.BOF) then
					rs2.movefirst
					do until rs2.eof
						AMDATAID = rs2("AM_DATA_ID")
						AMID2 = rs2("AM_ID")
						AMCOUNT2 = rs2("AM_COUNT") -1
						AMNAME = rs2("AM_NAME")

or here...

Code:
								If AMCOUNT2 < AMCOUNT then
									'We edit and write back the entry by incrementing the count
									UpdSql = ""
									UpdSql = "UPDATE " & strMemberTablePrefix & "AM_DATA SET "
									UpdSql = UpdSql & "AM_COUNT = " & AMCOUNT2 +1 & ""
									UpdSql = UpdSql & " WHERE (((AM_ID)="& AMID & ") AND ((AM_NAME)='" & AMNAME & "'))"
									set rs3 = my_conn.execute(UpdSql ,adOpenStatic,adCmdTxt)
									AlertShow = True
								End If


Jeff Baldwin
sig2.gif
 
Try searching the page for somrhing like

"If AlertShow = True Then..."

or try searching for all instances of alertshow. Look for <script> tags and see if there is a function in those tags that looks like it might be a pop up. Search for that function name in the script as well.
 
Which page? It occurs on every page of the forum no matter what, everytime. It seems to me like the code isn't adjusting the members AM_COUNT when a pop up shows. So when the code is rerun again (with a page refresh or if the user browses to another page in the forum) the database is saying "this user hasn't seen the alert yet, show it!"

Jeff Baldwin
sig2.gif
 
I would browse to one of the pages that displays this problem and then do a "view source" to get a good look at the script and html that the browser is actually processing.

Perhaps this would allow me to spot the problem and then I could work backwards from there to identify the problem in the server-side logic.
 
This is the source code from the main default page of my forum...the pop up script is actually the last line of code in the text file.

Source.txt

Here is a copy of inc_footer.asp (which is where the include file inc_alert {from above} is inserted into) inc_footer.asp is referenced by every page in the forum as it includes the closing </body></html> tags. The inc_alert.asp include is just about the last line in the code.

Footer.txt

It's a ton of code for two pages , but I've pointed out where inc_alert.asp is referenced in them. I really do appreciate your help and you taking the time to try and assist me . Thanks.

Jeff Baldwin
sig2.gif
 
Ok i see the line you were talking about at the bottom:
Code:
<script language="Javascript">alert ("This is a test alert.  I apologize if this keeps popping up for you with every page.  It should only pop up twice - Thanks, Admin")</script>

That link for footer.txt doesnt work but i assume it is referring to the same code as inc_alert.txt from above?

If so then I have to ask about this... first you take one less than the count...
[tt]AMCOUNT2 = rs2("AM_COUNT") - 1[/tt]

... but then when you update the row, you just add that one back:
[tt]"AM_COUNT = " & AMCOUNT2 + 1 [/tt]

It seems if you really wanted this number to grow then you'd add 2... or not subtract the 1 in the first place.
 
Code:
'We first see if we have a cookie from a member
CookieText = Request.Cookies("Snitz00User")("Name")

'If the length of the cookie is bad then stop right here!
If (Len(CookieText) = 0) Then
  Response.Write "Cookie error!"
  Response.End
End If


'The cookie must be good if we made it this far!
'Get all alerts remaining for this user
Set my_conn = Server.CreateObject("ADODB.Connection")
my_conn.Open strConnString
strSQL = "SELECT A.AM_ID, A.AM_TEXT, A.AM_COUNT 'AlertsToDo' " _
       & "B.AM_DATA_ID , B.AM_NAME, B.AM_COUNT 'AlertsDone' " _
       & "FROM " & strMemberTablePrefix & "AM A " _
       & "LEFT JOIN " & strMemberTablePrefix & "AM_DATA B " _
       & "ON A.AM_ID = B.AM_ID " _
       & "AND '" & Now & "' BETWEEN A.AM_START AND A.AM_END " _
       & "WHERE ((B.AM_NAME = '" & CookieText & "') or (B.AM_NAME Is Null)) " _
       & "AND ((B.AM_COUNT < A.AM_COUNT) or (B.AM_COUNT Is Null)) "

Set rs = my_conn.Execute(strSQL)   'default forward only/read only recordset is fine
If (rs.State <> 1) Then
  Set rs = Nothing
  my_conn.Close
  Set my_conn = Nothing
  Response.Write "<br>ADO error!<br>" & strSQL
  Response.End
End If

Set rs.ActiveConnection = Nothing  'disconnect the recordset
Do While Not rs.EOF
  If IsNull(rs("AlertsDone")) Then
    'Do Insert -- (assuming AM_COUNT never = 0 on table AM_DATA)
    strSQL = "INSERT INTO " & strMemberTablePrefix & "AM_DATA " _
           & "(AM_ID, AM_NAME, AM_COUNT) VALUES (" _
           & rs("AM_ID") & ",'" & CookieText & "',1)"
  Else
    'Do Update
    strSQL = "UPDATE " & strMemberTablePrefix & "AM_DATA SET " _
           & "AM_COUNT = " & rs("AlertsDone") + 1 & " " _
           & "WHERE AM_DATA_ID = " & rs("AM_DATA_ID")
  End If
  
  Response.Write "<script language=""Javascript"">"
  Response.Write "alert(""" & rs("AMTEXT") & """);"
  Response.Write "</script>" & vbCRLF
  
  my_conn.Execute strSQL
  rs.MoveNext
Loop

'close up shop
rs.Close
Set rs = Nothing
my_conn.Close
Set my_conn = Nothing
 
Wow, thanks for the effort you have given to my problem! I truly appreciate it. However, I am now getting this error...

Code:
Microsoft JET Database Engine error '80040e14' 

Syntax error (missing operator) in query expression 'A.AM_COUNT 'AlertsToDo' B.AM_DATA_ID'. 

/forum/forum2/inc_alert.asp, line 43

Jeff Baldwin
sig2.gif
 
ah that looks like a missing comma:
A.AM_COUNT 'AlertsToDo'[red],[/red] B.AM_DATA_ID

Also my syntax assumed MSSQL Server... it might be that MSAccess will require the use of the "As" keyword when doing an alias for fields and/or tables.
 
so if it later complains about the missing As then try:[tt]
A.AM_COUNT [red]As[/red] 'AlertsToDo'[red],[/red] B.AM_DATA_ID[/tt]
 
I truly apologize for being such a pain, but now I get error:

Microsoft JET Database Engine error '80040e14'

Between operator without And in query expression ''.

/forum/forum2/inc_alert.asp, line 43

I also emailed the author of the mod to see if he ever came up with a fix for the problem, but this was written a while ago, so I'm not sure if I expect a response from him or not. Thanks again Sheco, sorry to bother you.

Jeff Baldwin
sig2.gif
 
Maybe it needs some more parenthesis
[tt]
& "AND [red]([/red]'" & Now & "' BETWEEN A.AM_START AND A.AM_END[red])[/red] " _[/tt]

You might try adding a [tt]Response.Write strSQL[/tt] in there right before executing the query so that you can copy it into Access and make sure the syntax is good.
 
Hmmm. I remember reading that JOIN expressions arent supported by Access. Now I am getting that error. JOIN expression not supported. I appreciate your help Sheco, but I honestly do not want to take up any more of your time. Thank you again.

Jeff Baldwin
sig2.gif
 
COuld it also possibly have something to do with the Access DB table? Namely the type of fields originally created?

Code:
Alert Members
[CREATE]
AM
AM_ID
AM_START#varchar(255)#NULL#
AM_END#varchar(255)#NULL#
AM_TEXT#varchar(255)#NULL#
AM_COUNT#int#NULL#
[END]
[CREATE]
AM_DATA
AM_DATA_ID
AM_ID#int#NULL#
AM_NAME#varchar(255)#NULL#
AM_COUNT#int#NULL#
[END]

Jeff Baldwin
sig2.gif
 
The reason I ask is because when I set up the alert in the admin section, it says the START DATE and the END DATE MUST be in the format of YYYYMMDD, but when I did the Response.Write strSQL the date comes out in this format:

Code:
'5/8/2006 4:03:10 PM'

Here are the results of the entire strSQL:

Code:
SELECT A.AM_ID, A.AM_TEXT, A.AM_COUNT AS 'AlertsToDo', B.AM_DATA_ID , B.AM_NAME, B.AM_COUNT AS 'AlertsDone' FROM FORUM_AM A LEFT JOIN FORUM_AM_DATA B ON A.AM_ID = B.AM_ID AND ('5/8/2006 4:03:10 PM' BETWEEN A.AM_START AND A.AM_END) WHERE ((B.AM_NAME = 'JBaldwin') or (B.AM_NAME Is Null)) AND ((B.AM_COUNT < A.AM_COUNT) or (B.AM_COUNT Is Null)) 

Microsoft JET Database Engine error '80040e14' 

Join expression not supported. 

/forum/forum2/inc_alert.asp, line 45

Jeff Baldwin
sig2.gif
 
Access can do joins.

So we are trying to do this:[tt]
FROM AM A
LEFT JOIN AM_DATA B
ON A.AM_ID = B.AM_ID
AND ('" & Now & "' BETWEEN A.AM_START AND A.AM_END) [/tt]


Maybe it wants to see the "as" keyword?:[tt]
FROM AM as A
LEFT JOIN AM_DATA as B
ON A.AM_ID = B.AM_ID
AND ('" & Now & "' BETWEEN A.AM_START AND A.AM_END) [/tt]



Or maybe it doesn't like the way the extra conditional is part of the join condition... maybe Access would rather see that down in the WHERE clause:[tt]
FROM AM A
LEFT JOIN AM_DATA B
ON A.AM_ID = B.AM_ID
WHERE
((B.AM_NAME = '" & CookieText & "') or (B.AM_NAME Is Null))
AND ((B.AM_COUNT < A.AM_COUNT) or (B.AM_COUNT Is Null))
AND ('" & Now & "' BETWEEN A.AM_START AND A.AM_END)
[/tt]

 
still no luck, sorry.

First suggestion results with same error.

Second suggestion results with:

Code:
SELECT A.AM_ID, A.AM_TEXT, A.AM_COUNT AS 'AlertsToDo', B.AM_DATA_ID , B.AM_NAME, B.AM_COUNT AS 'AlertsDone' FROM FORUM_AM_DATA A LEFT JOIN FORUM_AM_DATA B ON A.AM_ID = B.AM_ID WHERE ((B.AM_NAME = 'JBaldwin') or (B.AM_NAME Is Null)) AND ((B.AM_COUNT < A.AM_COUNT) or (B.AM_COUNT Is Null)) AND ('5/8/2006 4:19:47 PM' BETWEEN A.AM_START AND A.AM_END) 

Microsoft JET Database Engine error '80040e10' 
No value given for one or more required parameters. 
/forum/forum2/inc_alert.asp, line 45

::sigh:: Probably best to alert people using forum wide email instead. I just liked the "instant notice" characteristics of the pop-up


Jeff Baldwin
sig2.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top