/    Sign up×
Community /Pin to ProfileBookmark

Removing ‘ character from a string

Hi,
I have a ‘ character in a string, so I cant add this to a mysql database, how can I add this string and still display the ‘ character when I read from the database?

Many thanks

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@mintedjoFeb 17.2009 — Maybe...

Use "" to encapsulate the string in your code instead of '?

Something like [CODE]INSERT INTO myTable VALUES("is", "isn't");[/CODE]
Or escape it with a backslash?

Something like [CODE]INSERT INTO myTable VALUES('is', 'isn't');[/CODE]
Copy linkTweet thisAlerts:
@livewire1974authorFeb 17.2009 — coool, thanks
Copy linkTweet thisAlerts:
@criterion9Feb 17.2009 — To change your string on the fly you can use:
str_replace("'","'",$your_string);
http://www.php.net/manual/en/function.str-replace.php
Copy linkTweet thisAlerts:
@andre4s_yFeb 17.2009 — Please take a look at :

mysql_escape_string() function,

mysql_real_escape_string() function, and

Magic Quote directives.
×

Success!

Help @livewire1974 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...