Solved

PHP - Speach Marks in Form Problem

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

861 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now