ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP Development

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 ASP Free Forums Sponsor:
  #1  
Old June 13th, 2004, 07:06 PM
Seeker Seeker is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 15 Seeker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 29 m 20 sec
Reputation Power: 0
Problems with blank spaces

Hi there. I'm trying to delete ' from strings that i'm going to use in a SQL query. I have this now:

function RemoveChars(input)
input = Replace(input,"'","")
End Function

The thing is, all the ' will turn into blanks(spaces) and I need to get rid of them as well, so i tried this:

function RemoveChars(input)
input = Replace(input,"'","")
inout = Trim(input)
End Function

But it didn't work. Any suggestions?
Also, should I have a:
Response.Write input
in the bottom before End function? When should I add that string?

Thanks

Seeker

Reply With Quote
  #2  
Old June 13th, 2004, 09:39 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,879 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 18 h
Reputation Power: 500
Why do you need to get rid of them?

Reply With Quote
  #3  
Old June 14th, 2004, 06:57 AM
Seeker Seeker is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 15 Seeker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 29 m 20 sec
Reputation Power: 0
This is my code:

function RemoveChars(input)
input = Replace(input,"'","")
Response.Write input
End Function

Strkeyword = RemoveChars(request.form("keyword"))

if strkeyword ="" then
response.redirect("search.asp?name=Search&msg=typekeyword")
end if


It will give me a Strkeyword = "" which it shouldn't ?
I will also use the Strkeyword as:

rs = "SELECT * FROM users where user LIKE '%"&strkeyword&"%' OR d LIKE '%"&strkeyword&"%'"
set sql = connect.execute(rs)



//Seeker

Reply With Quote
  #4  
Old June 14th, 2004, 09:31 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,879 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 18 h
Reputation Power: 500
You didn't answer my question.
WHY do you need to remove the (') single quotes?

Reply With Quote
  #5  
Old June 14th, 2004, 11:16 AM
Seeker Seeker is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 15 Seeker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 29 m 20 sec
Reputation Power: 0
Quote:
Originally Posted by Seeker

rs = "SELECT * FROM users where user LIKE '%"&strkeyword&"%' OR d LIKE '%"&strkeyword&"%'"
set sql = connect.execute(rs)

^^ That is why. You are problaby aware of the complications when trying to make a SQL query when there are (')s in it.
I don't understand why my function won't work?

Reply With Quote
  #6  
Old June 14th, 2004, 11:52 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,879 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 18 h
Reputation Power: 500
You don't need to remove them, just double them.
Code:
strSql = "SELECT * FROM [users] WHERE username LIKE '%" & ReplaceQuotes(strKeyword) & "%' OR d LIKE '%" & ReplaceQuotes(strKeyword) & "%'"

Set rs = Conn.Execute(strSql)

Function ReplaceQuotes(strValue)
   strValue = Replace(strValue, "'", "''")

   ReplaceQuotes = strValue
End Function

Reply With Quote
  #7  
Old June 14th, 2004, 03:53 PM
Seeker Seeker is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 15 Seeker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 29 m 20 sec
Reputation Power: 0
Ok thank you mat, that will come in handy.
But let's pretend I'd like to remove them instead, just for learning, how should i do? Why won't my original function work??


//Seeker

Reply With Quote
  #8  
Old June 14th, 2004, 05:02 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,879 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 18 h
Reputation Power: 500
You weren't returning the value in your function.
Do this.
Code:
strValue = "Mark's"

Response.write(RemoveChars(strValue))

Function RemoveChars(input)
   input = Replace(input,"'","")

   RemoveChars = input
End Function

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > Problems with blank spaces


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 6 hosted by Hostway
Stay green...Green IT