Solved

how do I get rid of an apostrophe with php?

Posted on 2011-02-15
2
324 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

751 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