|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Hi, I'm using ASP as frontend with MySQL as backend, and Dundas Mailer as the email object. I'm making a contact form where the submitted datat would be inserted in the database first and then using Dundas for mail ...
But I have tried to include strange characters like " ' in the message field. But return error ... So help is needed! Much appreciated your efforts!
__________________
Agnes
|
|
#2
|
|||
|
|||
|
Hi Agnes,
Well, as I understand your message has characters like [ ' ] and this is creating the problem right ? If yes, then this is the prob. If you are inserting the data with a SQL, [ ' ] would be treated as part of the SQL command and not as a text info. If you could submit the code, might be able to help you more.... Regards |
|
#3
|
||||
|
||||
|
Ah, the code is quite long ...
<% Dim strTitle, strCountry, strInfoSource Dim strEmail, strFirstName, strLastName, strCompany, strAddress1, strAddress2 Dim strCity, strProvince, strPostalCode, strPhone, strFax, strURL Dim strComment, strIP, strDate, strTime If Request.Form("Title") = "--" Then strTitle = "" Else strTitle = Request.Form("Title") If Request.Form("Country") = "--Please select country--" Then strCountry = "" Else strCountry = Request.Form("Country") If Request.Form("InfoSource") = "Please Choose One" Then strInfoSource = "" Else strInfoSource = Request.Form("InfoSource") strFirstName = Request.Form("FirstName") strLastName = Request.Form("LastName") strCompany = Request.Form("Company") strAddress1 = Request.Form("Address1") strAddress2 = Request.Form("Address2") strCity = Request.Form("City") strProvince = Request.Form("Province") strPostalCode = Request.Form("PostalCode") strPhone = Request.Form("Phone") strFax = Request.Form("Fax") strURL = Request.Form("URL") strComment = Request.Form("Comment") strEmail = Request.Form("Email") strDate = year(date) & "/" & month(date) & "/" & day(date) strTime = TIME strIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR") If strIP="" Then strIP = Request.ServerVariables("REMOTE_ADDR") %> <% mySQL= "INSERT INTO ncontact" mySQL= mySQL & "(FirstName,LastName,Title,Email,Company,Address1,Address2,City,Province,PostalCode,Country,Phone,Fax ,URL,InfoSource,Comment,IP,Date,Time)" mySQL= mySQL & "VALUES ('" & strFirstName & "','" mySQL= mySQL & strLastName & "'" mySQL= mySQL & ",'" & strTitle & "'" mySQL= mySQL & ",'" & strEmail & "'" mySQL= mySQL & ",'" & strCompany & "'" mySQL= mySQL & ",'" & strAddress1 & "'" mySQL= mySQL & ",'" & strAddress2 & "'" mySQL= mySQL & ",'" & strCity & "'" mySQL= mySQL & ",'" & strProvince & "'" mySQL= mySQL & ",'" & strPostalCode & "'" mySQL= mySQL & ",'" & strCountry & "'" mySQL= mySQL & ",'" & strPhone & "'" mySQL= mySQL & ",'" & strFax & "'" mySQL= mySQL & ",'" & strURL & "'" mySQL= mySQL & ",'" & strInfoSource & "'" mySQL= mySQL & ",'" & strComment & "'" mySQL= mySQL & ",'" & strIP & "'" mySQL= mySQL & ",'" & strDate & "'" mySQL= mySQL & ",'" & strTime & "')" myConn.Execute mySQL %> <!-- Send e-mail part --> <% Dim objEmail 'stores a Mailer control object 'The SendMail function will throw an exception if the operation is ' unsuccessful, so we enable inline error trapping On Error Resume Next Set objEmail = Server.CreateObject("Dundas.Mailer") 'Mailer object 'initialize the HtmlBody property, we'll throw a header into it objEmail.HtmlBodyCharSet = "Cp1381" objEmail.HTMLBody = "<html><head><meta http-Equiv=Content-Type content=text/html;charset=utf-8><style>body {font-size:9pt;font-family:Verdana;background-color:#ffffff}" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "td {font-size:9pt;vertical-align:top;font-family:Verdana}</style></head>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<body><p>Click REPLY if you want to reply to the enquirer.</p>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<table border=0 cellpadding=3 cellspacing=1 bgcolor=#CDCDCD width=600>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<tr><td bgcolor=#E6E6EF colspan=2><b>You receive an enquiry from web on " objEmail.HTMLBody = objEmail.HTMLBody & strDate objEmail.HTMLBody = objEmail.HTMLBody & " " objEmail.HTMLBody = objEmail.HTMLBody & strTime objEmail.HTMLBody = objEmail.HTMLBody & "</b></td></tr>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<tr><td bgcolor=#ffffff width=150>Title</td>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<td bgcolor=#ffffff width=450>" objEmail.HTMLBody = objEmail.HTMLBody & strTitle objEmail.HTMLBody = objEmail.HTMLBody & "</td></tr>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<tr><td bgcolor=#fffff3 width=150>First Name</td>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<td bgcolor=#fffff3 width=450>" objEmail.HTMLBody = objEmail.HTMLBody & strFirstName objEmail.HTMLBody = objEmail.HTMLBody & "</td></tr>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<tr><td bgcolor=#ffffff width=150>Last Name</td>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<td bgcolor=#ffffff width=450>" objEmail.HTMLBody = objEmail.HTMLBody & strLastName objEmail.HTMLBody = objEmail.HTMLBody & "</td></tr>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<tr><td bgcolor=#fffff3 width=150>E-mail</td>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<td bgcolor=#fffff3 width=450>" objEmail.HTMLBody = objEmail.HTMLBody & strEmail objEmail.HTMLBody = objEmail.HTMLBody & "</td></tr>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<tr><td bgcolor=#ffffff width=150>Company Name</td>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<td bgcolor=#ffffff width=450>" objEmail.HTMLBody = objEmail.HTMLBody & strCompany objEmail.HTMLBody = objEmail.HTMLBody & "</td></tr>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<tr><td bgcolor=#fffff3 width=150>Address</td>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<td bgcolor=#fffff3 width=450>" objEmail.HTMLBody = objEmail.HTMLBody & strAddress1 objEmail.HTMLBody = objEmail.HTMLBody & "<br>" objEmail.HTMLBody = objEmail.HTMLBody & strAddress2 objEmail.HTMLBody = objEmail.HTMLBody & "</td></tr>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<tr><td bgcolor=#ffffff width=150>City</td>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<td bgcolor=#ffffff width=450>" objEmail.HTMLBody = objEmail.HTMLBody & strCity objEmail.HTMLBody = objEmail.HTMLBody & "</td></tr>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<tr><td bgcolor=#fffff3 width=150>State / Zip</td>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<td bgcolor=#fffff3 width=450>" objEmail.HTMLBody = objEmail.HTMLBody & strProvince objEmail.HTMLBody = objEmail.HTMLBody & strPostalCode objEmail.HTMLBody = objEmail.HTMLBody & "</td></tr>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<tr><td bgcolor=#ffffff width=150>Country</td>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<td bgcolor=#ffffff width=450>" objEmail.HTMLBody = objEmail.HTMLBody & strCountry objEmail.HTMLBody = objEmail.HTMLBody & "</td></tr>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<tr><td bgcolor=#fffff3 width=150>Phone</td>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<td bgcolor=#fffff3 width=450>" objEmail.HTMLBody = objEmail.HTMLBody & strPhone objEmail.HTMLBody = objEmail.HTMLBody & "</td></tr>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<tr><td bgcolor=#ffffff width=150>Fax</td>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<td bgcolor=#ffffff width=450>" objEmail.HTMLBody = objEmail.HTMLBody & strFax objEmail.HTMLBody = objEmail.HTMLBody & "</td></tr>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<tr><td bgcolor=#fffff3 width=150>URL</td>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<td bgcolor=#fffff3 width=450>" objEmail.HTMLBody = objEmail.HTMLBody & strURL objEmail.HTMLBody = objEmail.HTMLBody & "</td></tr>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<tr><td bgcolor=#ffffff width=150>InfoSource</td>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<td bgcolor=#ffffff width=450>" objEmail.HTMLBody = objEmail.HTMLBody & strInfoSource objEmail.HTMLBody = objEmail.HTMLBody & "</td></tr>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<tr><td bgcolor=#fffff3 width=150>Comment</td>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "<td bgcolor=#fffff3 width=450>" objEmail.HTMLBody = objEmail.HTMLBody & strComment objEmail.HTMLBody = objEmail.HTMLBody & "</td></tr>" & vbcrlf objEmail.HTMLBody = objEmail.HTMLBody & "</table></body></html>" objEmail.TOs.Add "email@email.com" 'specify the subject of the email objEmail.Subject = "Web Enquiries" 'specify the sender of the message objEmail.FromAddress = strEmail objEmail.SMTPRelayServers.Add "mail.isp.com" 'send the email objEmail.SendMail %> |
|
#4
|
|||
|
|||
|
Hi Agnes,
Continuing from my previous reply..., If my assumption of the problem is right, you might want to try out this fix... To insert an apostrophe into the database using SQL you need to "double-up" the apostrophes, that is put two apostrophes in the text where you want just one. For example, if you want to insert the phrase "what's up?" into a database the SQL code would look like: INSERT INTO mytable (phrases) VALUES ('what''s up?') Hope this helps... Regards |
|
#5
|
|||
|
|||
|
Hi Agnes,
Here is a link which explains the exact reason for your problem and also provides a solution. http://www.aspfaqs.com/ASPscripts/P...Q.asp?FAQID=137 Regards |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Form Post with MySQL as backend |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|