Forums
This topic is locked
MM_Username value when not logged in
28 May 2006 21:42:48 Wim Conix posted:
Hi all,I'm trying to create a IF..THEN..ELSE which looks for the user login (or not) to show/hide delete button.
When logged in (with the correct username or another) it works perfect, as a visitor (not logged in) I get BOF/EOF error.
What's the value to check for MM_Username ?
Or another way to check for login ?
Code :
<%IF (Recordset2.Fields.Item("UsrID".Value) = (Recordset3.Fields.Item("ID".Value) THEN%><a href="delete.asp?ID=<%=(Recordset2.Fields.Item("ID".Value)%>&user=<%=(Recordset2.Fields.Item("Author".Value)%>"><img src="../../images_site/delete.jpg" alt="Delete this message" width="17" height="17" border="0"></a><%ELSE IF Session("MM_Username" IS NULL THEN Response.Write "" ELSE Response.Write "" END IF END IF%>
Thanks for any help,
Wim
Wim Conix
www.image-belle.com
Edited by - dannybrison on 28 May 2006 21:57:54
Replies
Replied 29 May 2006 08:25:16
29 May 2006 08:25:16 micah santos replied:
your problem is very simple, yet, the way you represent it is very confusing...
anyways, based on your code, you don't have to use the ELSE part co'z it's absolutely null.
e.g.
<%
IF (Recordset2.Fields.Item("UsrID".Value) = (Recordset3.Fields.Item("ID".Value) THEN
%>
<a href="delete.asp?ID=<%=(Recordset2.Fields.Item("ID".Value)%>&user=<%=(Recordset2.Fields.Item("Author".Value)%>"><img src="../../images_site/delete.jpg" alt="Delete this message" width="17" height="17" border="0"></a>
<%
END IF
%>
anyways, based on your code, you don't have to use the ELSE part co'z it's absolutely null.
e.g.
<%
IF (Recordset2.Fields.Item("UsrID".Value) = (Recordset3.Fields.Item("ID".Value) THEN
%>
<a href="delete.asp?ID=<%=(Recordset2.Fields.Item("ID".Value)%>&user=<%=(Recordset2.Fields.Item("Author".Value)%>"><img src="../../images_site/delete.jpg" alt="Delete this message" width="17" height="17" border="0"></a>
<%
END IF
%>
Replied 29 May 2006 12:20:48
29 May 2006 12:20:48 Wim Conix replied:
Thanks Micah for the quick answer !
However, still getting the same error.
UsrID is the numeric ID of the User, Recordset3 ID is the UsrID retreived from the login (MM_Username).
Working fine when logged in as whoever user (showing/hiding the image correctly), but when not logged in at all, getting BOF/EOF error.
You can see for yourself : wimley.image-belle.com ==> Go to the Guestbook.
<%IF (Recordset2.Fields.Item("UsrID".Value) = (Recordset3.Fields.Item("ID".Value) THEN%><a href="delete.asp?ID=<%=(Recordset2.Fields.Item("ID".Value)%>&user=<%=(Recordset2.Fields.Item("Author".Value)%>"><img src="../../images_site/delete.jpg" alt="Delete this message" width="17" height="17" border="0"></a><%END IF%>
Sorry for representing it a bit difficult...
Thanks,
Wim
Wim Conix
www.image-belle.com
However, still getting the same error.
UsrID is the numeric ID of the User, Recordset3 ID is the UsrID retreived from the login (MM_Username).
Working fine when logged in as whoever user (showing/hiding the image correctly), but when not logged in at all, getting BOF/EOF error.
You can see for yourself : wimley.image-belle.com ==> Go to the Guestbook.
<%IF (Recordset2.Fields.Item("UsrID".Value) = (Recordset3.Fields.Item("ID".Value) THEN%><a href="delete.asp?ID=<%=(Recordset2.Fields.Item("ID".Value)%>&user=<%=(Recordset2.Fields.Item("Author".Value)%>"><img src="../../images_site/delete.jpg" alt="Delete this message" width="17" height="17" border="0"></a><%END IF%>
Sorry for representing it a bit difficult...
Thanks,
Wim
Wim Conix
www.image-belle.com
Replied 29 May 2006 13:03:02
29 May 2006 13:03:02 Patrick Woldberg replied:
try:
<% If Not Recordset3.EOF And (Recordset2.Fields.Item("UsrID".Value) = (Recordset3.Fields.Item("ID".Value) Then %>
<a href="delete.asp?ID=<%=(Recordset2.Fields.Item("ID".Value)%>&user=<%=(Recordset2.Fields.Item("Author".Value)%>"><img src="../../images_site/delete.jpg" alt="Delete this message" width="17" height="17" border="0"></a>
<% End If %>
If it still gives an error you should use:
<%
If Not Recordset3.EOF Then
If (Recordset2.Fields.Item("UsrID".Value) = (Recordset3.Fields.Item("ID".Value) Then
%>
<a href="delete.asp?ID=<%=(Recordset2.Fields.Item("ID".Value)%>&user=<%=(Recordset2.Fields.Item("Author".Value)%>"><img src="../../images_site/delete.jpg" alt="Delete this message" width="17" height="17" border="0"></a>
<%
End If
End If
%>
--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Administrator at DMXzone.com, FLzone.net, FWzone.net and DNzone.com
--------------------------------------------------
<% If Not Recordset3.EOF And (Recordset2.Fields.Item("UsrID".Value) = (Recordset3.Fields.Item("ID".Value) Then %>
<a href="delete.asp?ID=<%=(Recordset2.Fields.Item("ID".Value)%>&user=<%=(Recordset2.Fields.Item("Author".Value)%>"><img src="../../images_site/delete.jpg" alt="Delete this message" width="17" height="17" border="0"></a>
<% End If %>
If it still gives an error you should use:
<%
If Not Recordset3.EOF Then
If (Recordset2.Fields.Item("UsrID".Value) = (Recordset3.Fields.Item("ID".Value) Then
%>
<a href="delete.asp?ID=<%=(Recordset2.Fields.Item("ID".Value)%>&user=<%=(Recordset2.Fields.Item("Author".Value)%>"><img src="../../images_site/delete.jpg" alt="Delete this message" width="17" height="17" border="0"></a>
<%
End If
End If
%>
--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Administrator at DMXzone.com, FLzone.net, FWzone.net and DNzone.com
--------------------------------------------------
Replied 29 May 2006 13:15:56
29 May 2006 13:15:56 Wim Conix replied:
Thanks Patrick !!
Working correctly with the second option...
Still getting errors in the other post issue... I'll post that there.
Wim
Wim Conix
www.image-belle.com
Working correctly with the second option...
Still getting errors in the other post issue... I'll post that there.
Wim
Wim Conix
www.image-belle.com