Solved

how can i escape apostrophe in mysql

Posted on 2010-08-22
3
730 Views
Last Modified: 2013-12-13
Hello i am facing a problem each entry have a " ' " apostrophe mysql update or insewrt is returing an error ! it can add it to the database so how can i escape it ! and fix the update or insert .
Thanks.
 
0
Comment
Question by:Styleminds
[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
3 Comments
 
LVL 30

Expert Comment

by:Brad Howe
ID: 33496155
Hi,

Why not use the mysql escape character ?

http://dev.mysql.com/doc/refman/5.0/en/string-syntax.html

\'  A single quote (“'”) character.

You will take the string you want to insert and replace all (') with (\').

You could also just replace the apostrophes with ascii like such

$string = str_replace("'", "'", $string);

Cheers,
Hades666
0
 
LVL 4

Expert Comment

by:Frozenice
ID: 33496310
you simple do you so..

$string = htmlspecialchars($yourstring);


0
 
LVL 4

Accepted Solution

by:
Frozenice earned 500 total points
ID: 33496334
just an update..

you may also do so..


$cleanstring = mysql_real_escape_string($yourstring);
0

Featured Post

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

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

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…
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…
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 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 …

632 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