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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If statement broke!

Status
Not open for further replies.

stevemarsh99

Technical User
Aug 10, 2005
88
GB
Hey guys,

I have this page that is supposed to email someone based on a date that sits in a database. The code looks fine but when I run the page it ALWAYS comes back with the 'else' part of the if statement.....ARRRRRRHGGGHH! Any ideas?

(also taking for granted we could fix it, do you think the date would work if the hard coded date that I have used in the example would be replaced with asp code to dynamically display date date in a databse?)

*******************************************************

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/ealert.asp" -->
<%
Dim rs_ealert
Dim rs_ealert_numRows

Set rs_ealert = Server.CreateObject("ADODB.Recordset")
rs_ealert.ActiveConnection = MM_ealert_STRING
rs_ealert.Source = "SELECT * FROM tbl_ealert"
rs_ealert.CursorType = 0
rs_ealert.CursorLocation = 2
rs_ealert.LockType = 1
rs_ealert.Open()

rs_ealert_numRows = 0
%>


<% if 30/11/2005 = dateadd("d", date(), -1) then %>

<%

FormFields = "to~body~subject"
If FormFields <> "" Then
arrFormFields = split(FormFields,"~")
End If
Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.From = "Circulation@eAlert.com"
objCDO.To = "marsh@khl.com"
objCDO.Cc = ""
objCDO.Bcc = ""
objCDO.Subject = "WORKING!!"
BodyString = Replace("Extra Hard coded MAIN BODY text","~",chr(13) & chr(10) )& chr(13)
If FormFields <> "" Then
For Each item In arrFormFields
BodyString = BodyString & item & ": " & Request.Form(item) & chr(13)
Next
End If
objCDO.Body = BodyString
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send
Set objCDO = Nothing
RedirectURL = ""
If RedirectURL <> "" then
If Request.QueryString <> "" Then
response.redirect(RedirectURL & "?" & Request.QueryString)
else
response.redirect(RedirectURL)
end If
end if %>
<% else %>
<%
FormFields = "to~body~subject"
If FormFields <> "" Then
arrFormFields = split(FormFields,"~")
End If
Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.From = "Circulation@eAlert.com"
objCDO.To = "marsh@khl.com"
objCDO.Cc = ""
objCDO.Bcc = ""
objCDO.Subject = "Its the else of the 'if' statement"
BodyString = Replace("Extra Hard coded MAIN BODY text","~",chr(13) & chr(10) )& chr(13)
If FormFields <> "" Then
For Each item In arrFormFields
BodyString = BodyString & item & ": " & Request.Form(item) & chr(13)
Next
End If
objCDO.Body = BodyString
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send
Set objCDO = Nothing
RedirectURL = ""
If RedirectURL <> "" then
If Request.QueryString <> "" Then
response.redirect(RedirectURL & "?" & Request.QueryString)
else
response.redirect(RedirectURL)
end If
end if %>
<% end if %>


<% MM_EditAction = CStr(Request("URL"))
If (Request.QueryString <> "") Then
MM_EditAction = MM_EditAction & "?" & Request.QueryString
End If
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<head>
<title>KHL Digital Magazine eAlerts</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
-->
</style>
<link href="css/Main_page.css" rel="stylesheet" type="text/css">
</head>

<body>

</body>
</html>
<%
rs_ealert.Close()
Set rs_ealert = Nothing
%>
*******************************************************
 
Brilliant, that works now. Another issue is that email form itself?

Would it be possible to add dynamic database data to the email form? I have tried adding it but it fails?

<%
if strToday = strMyDate and (rs_ealert.Fields.Item("LIST_CIRC").Value) = "No" then
%>
<%
FormFields = "to~body~subject"
If FormFields <> "" Then
arrFormFields = split(FormFields,"~")
End If
Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.From = "eAlert@khl.com"
objCDO.To = (rs_ealert.Fields.Item("READY_CONTACT").Value)
objCDO.Cc = ""
objCDO.Bcc = ""
objCDO.Subject = "KHL eAlert Workflow Reminder...Circulation Lists are not Complete yet" ******DYNAMIC DATA HERE??*********
BodyString = Replace("YAY it works when I want it too!....I love you really!","~",chr(13) & chr(10) )& chr(13)

objCDO.Body = BodyString
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send
Set objCDO = Nothing %>

<% else %>

<% Response.Write(" ") %>
<% end if %>
 
Oh crap we have another problem...i get the following error with this code:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/ealert.asp" -->
<%
Dim rs_ealert
Dim rs_ealert_numRows

Set rs_ealert = Server.CreateObject("ADODB.Recordset")
rs_ealert.ActiveConnection = MM_ealert_STRING
rs_ealert.Source = "SELECT * FROM tbl_ealert"
rs_ealert.CursorType = 0
rs_ealert.CursorLocation = 2
rs_ealert.LockType = 1
rs_ealert.Open()

rs_ealert_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rs_ealert_numRows = rs_ealert_numRows + Repeat1__numRows
%>
<%
' *** Add Current Date To Page ***
' *** RobGT Server Behaviour 101 - By RobGT - ***
Dim tempdaynow, daynow, datenow, tempmonthnow, monthnow, yearnow, RobGT_completedate
tempdaynow = Weekday(Date)
daynow = WeekdayName(tempdaynow)
datenow = Day(Date)
tempmonthnow = Month(Date)
monthnow = MonthName(tempmonthnow)
yearnow = Year(Date)
RobGT_completedate = "" & daynow &", "& datenow &" "& monthnow &" "& yearnow
%>
<%
strToday = dateadd("d", date(), 1)
strMyDate = (rs_ealert.Fields.Item("MAGDATE").Value)
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<head>
<title>KHL Digital Magazine eAlerts</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
-->
</style>
<link href="css/Main_page.css" rel="stylesheet" type="text/css">
</head>

<body>
<p>&nbsp;</p>
<table width="583" border="0" align="center" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td colspan="2" rowspan="2" valign="top"><a href="admin/Sent.asp"><img src="images/khlgroup.gif" width="88" height="65" border="0"></a></td>
<td width="103" height="31">&nbsp;</td>
<td colspan="5" class="DateText"><div align="right"><%=RobGT_completedate%></div></td>
</tr>
<tr>
<td height="40">&nbsp;</td>
<td colspan="5" valign="top" align="right"><img src="images/DIGI_EALERT.gif" width="287" height="31"></td>
</tr>
<tr>
<td height="10" colspan="8" valign="top" class="TopMargin"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td height="19" valign="top" class="LeftMargin"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td class="WhiteBlank">&nbsp;</td>
<td class="Headings">Up Date </td>
<td class="Headings">Circ lists </td>
<td class="Headings">Adv Lists </td>
<td class="Headings">Digital Copy </td>
<td class="Headings">Editor Text </td>
<td width="17" valign="top" class="RightMargin"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT rs_ealert.EOF))
%>
<%If (Repeat1__numRows Mod 2) Then%>
<tr bgcolor="#E4EDFA">
<%End If%>
<td width="11" height="47" valign="top" class="LeftMargin"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td width="92" class="WhiteBlank"><img src="<%=(rs_ealert.Fields.Item("MAGLOGO").Value)%>" class="ImageBorder" align="left"></td>
<td class="RedNormalText" align="center"><%=(rs_ealert.Fields.Item("MAGDATE").Value)%><br></td>
<td width="89" class="MainNormalText" align="center">


<% IF (rs_ealert.Fields.Item("LIST_CIRC").Value) = "Yes" Then%>
<img src="images/thumbs_up.gif">
<% ElseIf (rs_ealert.Fields.Item("LIST_CIRC").Value) = "No" Then %>
<img src="images/thumbs_down.gif">
<% End IF %>

<%
if strToday = strMyDate and (rs_ealert.Fields.Item("LIST_CIRC").Value) = "No" then
%>
<%
FormFields = "to~body~subject"
If FormFields <> "" Then
arrFormFields = split(FormFields,"~")
End If
Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.From = "eAlert@khl.com"
objCDO.To = (rs_ealert.Fields.Item("LIST_CIRC_CONTACT").Value)
objCDO.Cc = ""
objCDO.Bcc = ""
objCDO.Subject = "KHL eAlert Workflow Reminder...Circulation"
BodyString = Replace("Circulation Lists are not Complete yet","~",chr(13) & chr(10) )& chr(13)

objCDO.Body = BodyString
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send
Set objCDO = Nothing %>

<% else %>

<% Response.Write(" ") %>
<% end if %>

</td>
<td width="88" class="MainNormalText" align="center">

<% IF (rs_ealert.Fields.Item("LIST_ADV").Value) = "Yes" Then%>
<img src="images/thumbs_up.gif">
<% ElseIf (rs_ealert.Fields.Item("LIST_ADV").Value) = "No" Then %>
<img src="images/thumbs_down.gif">
<% End IF %>

<%
if strToday = strMyDate and (rs_ealert.Fields.Item("LIST_ADV").Value) = "No" then
%>
<%
FormFields = "to~body~subject"
If FormFields <> "" Then
arrFormFields = split(FormFields,"~")
End If
Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.From = "eAlert@khl.com"
objCDO.To = (rs_ealert.Fields.Item("LIST_ADV_CONTACT").Value)
objCDO.Cc = ""
objCDO.Bcc = ""
objCDO.Subject = "KHL eAlert Workflow Reminder...advertising"
BodyString = Replace("advertising Lists are not complete yet","~",chr(13) & chr(10) )& chr(13)

objCDO.Body = BodyString
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send
Set objCDO = Nothing %>

<% else %>

<% Response.Write(" ") %>
<% end if %>


</td>
<td width="103" class="MainNormalText"align="center">
<% IF (rs_ealert.Fields.Item("DIGITALISSUE").Value) = "proof" Then%>
<img src="images/proof.gif">
<% ElseIf (rs_ealert.Fields.Item("DIGITALISSUE").Value) = "ready" Then %>
<img src="images/ready.gif">
<% ElseIf (rs_ealert.Fields.Item("DIGITALISSUE").Value) = "incomplete" Then %>
<img src="images/incomplete.gif">
<% End IF %>

<%
if strToday = strMyDate and (rs_ealert.Fields.Item("DIGITALISSUE").Value) <> "ready" then
%>
<%
FormFields = "to~body~subject"
If FormFields <> "" Then
arrFormFields = split(FormFields,"~")
End If
Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.From = "eAlert@khl.com"
objCDO.To = (rs_ealert.Fields.Item("DIGITALISSUE_CONTACT").Value)
objCDO.Cc = ""
objCDO.Bcc = ""
objCDO.Subject = "KHL eAlert Workflow Reminder...Digital Issue"
BodyString = Replace("Digital issue is not complete yet","~",chr(13) & chr(10) )& chr(13)

objCDO.Body = BodyString
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send
Set objCDO = Nothing %>

<% else %>

<% Response.Write(" ") %>
<% end if %>

</td>
<td width="80" class="MainNormalText"align="center">

<% IF (rs_ealert.Fields.Item("EDITORTEXT").Value) = "Yes" Then%>
<img src="images/thumbs_up.gif">
<% ElseIf (rs_ealert.Fields.Item("EDITORTEXT").Value) = "No" Then %>
<img src="images/thumbs_down.gif">
<% End IF %>

<%
if strToday = strMyDate and (rs_ealert.Fields.Item("EDITORTEXT").Value) = "No" then
%>
<%
FormFields = "to~body~subject"
If FormFields <> "" Then
arrFormFields = split(FormFields,"~")
End If
Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.From = "eAlert@khl.com"
objCDO.To = (rs_ealert.Fields.Item("EDITORTEXT_CONTACT").Value)
objCDO.Cc = ""
objCDO.Bcc = ""
objCDO.Subject = "KHL eAlert Workflow Reminder...Editorial"
BodyString = Replace("Editorial 'taster text' has not been sent to the IT dept.","~",chr(13) & chr(10) )& chr(13)

objCDO.Body = BodyString
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send
Set objCDO = Nothing %>

<% else %>

<% Response.Write(" ") %>
<% end if %>

</td>


<td valign="top" class="RightMargin"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rs_ealert.MoveNext()
%>

<tr>
<td height="20" colspan="8" valign="top" class="BottomMargin"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
</table>
<br>
<table width="200" border="0" cellpadding="5" align="center">
<tr>
<td><a href="admin/Dates.asp"><img src="images/button_katy_saara.gif" width="152" height="26" border="0" class="ButtonPadding"></a></td>
<td colspan="2"><a href="admin/List.asp"><img src="images/button_siob_souhir.gif" width="152" height="26" border="0" class="ButtonPadding"></a></td>
<td><a href="admin/DigitalIssue.asp"><img src="images/button_jamie_philippa.gif" width="152" height="26" border="0" class="ButtonPadding"></a></td>
</tr>
<tr>
<td colspan="2"><div align="right"><a href="admin/editor.asp"><img src="images/button_editorial.gif" width="152" height="26" border="0"></a></div></td>
<td colspan="2"><a href="admin/Sent.asp"><img src="images/button_it.gif" width="152" height="26" border="0"></a></td>
</tr>
</table>
<p align="center" class="InformationText">
</body>
</html>

<%
rs_ealert.Close()
Set rs_ealert = Nothing
wend %>

And this error:

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required
/ealert/default.asp, line 80


Thoughts?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top