Solved

how do I get rid of an apostrophe with php?

Posted on 2011-02-15
2
323 Views
Last Modified: 2012-05-11
I have a php query and it's submitting the info to the database the problem is is if there is an apostrophe in the information that the client submits it messes up the query. Is there a way to strip out the apostrophe from the query?
0
Comment
Question by:anotherdotcommer
  • 2
2 Comments
 
LVL 9

Accepted Solution

by:
AriMc earned 500 total points
ID: 34901010
It depends on your database engine. If you're using MySQL then you could use mysql_real_escape_string function:

http://www.php.net/manual/en/function.mysql-real-escape-string.php

0
 
LVL 9

Expert Comment

by:AriMc
ID: 34901068
And for PostgreSQL, use  pg_escape_string:

http://www.php.net/manual/en/function.pg-escape-string.php

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
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.

735 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