navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

text box question

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> General Web Development >> text box question
Page: [1]
 
anand

 

Posts: 4
Joined: 5/24/2008
Status: offline

 
text box question - 5/24/2008 10:27:23   
Hi everyone,

I have a few text box's on my site and i would like to know how can i replace if a user enters a single quote ' and re-place it with nothing...

The problem i'm having is when a user enters a single quote i get an error on the page because this info gets inputed into a database...

Hope someone can help me...

[removed]

< Message edited by Mike54 -- 5/24/2008 10:34:43 >
Mane

 

Posts: 105
Joined: 7/7/2005
Status: offline

 
RE: text box question - 5/24/2008 17:49:58   
What language are you using? PHP? ASP?
It's better to read up on the language first before using it in a website, in order to create safe and secure pages.

To escape quotes in PHP use the addslashes() function:
$var = addslashes($var);

However members of this forum would certainly stress that it's important to learn the language first.

Mike54: You seem to have removed something from the post - If this was actually some intricate form of spam I'm sorry for responding.

(in reply to anand)
sarge

 

Posts: 377
From: London England
Status: offline

 
RE: text box question - 5/26/2008 21:16:20   
I use <% mytext = Replace(mytext, "'", "''") %>

That way the user's quote is preserved.

(in reply to Mane)
mtfm

 

Posts: 424
Joined: 1/13/2006
From: Mesa, AZ
Status: offline

 
RE: text box question - 5/27/2008 17:28:22   
There's also a Javascript method available, too.

I also substituted for the quote, but I put a - in place of it, because a single quote caused problems with the javascript. You could also replace it with nothing, just be removing the - from the code. Here's my code.

var variable_name = new_variable_name.replace (/"/g,'-');


You're basically taking your variable you should have already declared, manipulating it to remove the ' and declaring a new variable. Then when it comes time to insert the form result into your database, make sure that code calls the new variable name, and you're done.

On a side note, if you are doing much in javascript look into what's called "regular expressions." This is an example of one, and it is much, much easier than explicitly stating the if/then paramaters.



_____________________________

Is this possible? How about this? What about....?

(in reply to sarge)
Page:   [1]

All Forums >> Web Development >> General Web Development >> text box question
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts