Solved

PHP - Speach Marks in Form Problem

Posted on 2009-05-20
2
331 Views
Last Modified: 2012-05-07
I have a form and somebody entered 8" by 15" into it and it stopped my function working.

How can I clean up the posted text before I send it to my function for processing?
0
Comment
Question by:lwfuk
2 Comments
 
LVL 17

Accepted Solution

by:
Chris Harte earned 125 total points
ID: 24430402
Use the addslashes function.
If you are writing the content to a database use the mysqli_real_escape_string() instead to prevent injection attacks.
<?php
$str = "Is your name O'reilly?";
 
// Outputs: Is your name O\'reilly?
echo addslashes($str);
?>

Open in new window

0
 

Author Closing Comment

by:lwfuk
ID: 31583444
Many thanks.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question