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
Solved

how can i escape apostrophe in mysql

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Installer 5 38
Wordpress French and English Site 6 77
how to use a switch statement with heredoc 11 33
Accessing specific element - DOM PHP HTML 8 35
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
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.

829 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