ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 15th, 2003, 05:51 AM
hoagnes's Avatar
hoagnes hoagnes is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 61 hoagnes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 55 m 10 sec
Reputation Power: 6
Question Form Post with MySQL as backend

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

Reply With Quote
  #2  
Old December 15th, 2003, 06:13 AM
srinath srinath is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Bangalore, India.
Posts: 21 srinath User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to srinath
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

Reply With Quote
  #3  
Old December 15th, 2003, 06:18 AM
hoagnes's Avatar
hoagnes hoagnes is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 61 hoagnes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 55 m 10 sec
Reputation Power: 6
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

%>

Reply With Quote
  #4  
Old December 15th, 2003, 06:20 AM
srinath srinath is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Bangalore, India.
Posts: 21 srinath User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to srinath
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

Reply With Quote
  #5  
Old December 15th, 2003, 06:32 AM
srinath srinath is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Bangalore, India.
Posts: 21 srinath User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to srinath
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Form Post with MySQL as backend


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT