Solved

how can i escape apostrophe in mysql

Posted on 2010-08-22
3
725 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
  • 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

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

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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…
The viewer will learn how to dynamically set the form action using jQuery.
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…

947 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

19 Experts available now in Live!

Get 1:1 Help Now