Solved

PHP - Speach Marks in Form Problem

Posted on 2009-05-20
2
319 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

809 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