how to get rid of '\' from the database?
| User, date | Message |
|---|---|
|
Written by gilgal
5 years ago Category: General 32 posts since Wed, 12 Dec 07 |
I have inserted many words which have an apostrophe such as John's, Peter's...by putting \ with it. How do I get rid of that? |
|
Written by ansgar
5 years ago 3966 posts since Fri, 07 Apr 06 |
UPDATE mytable SET mycolumn = REPLACE(mycolumn, '\\ Just notice you have to escape a single quote and a backslash using a backslash! |
|
Written by gilgal
5 years ago 32 posts since Wed, 12 Dec 07 |
any double quote needed? UPDATE mytable SET mycolumn = REPLACE(mycolumn, '"\\'"', '"\'"') |
|
Written by gilgal
5 years ago 32 posts since Wed, 12 Dec 07 |
oh no I don't think so. |
|
Written by gilgal
5 years ago 32 posts since Wed, 12 Dec 07 |
Is that all that's needed or do I have to put WHERE and make loops? |
|
Written by gilgal
5 years ago 32 posts since Wed, 12 Dec 07 |
It doesn't seem to work. $sql = "UPDATE kjv SET text_data = REPLACE(text_data, '\', '')"; |
|
Written by gilgal
5 years ago 32 posts since Wed, 12 Dec 07 |
I have: <?php |
|
Written by ansgar
5 years ago 3966 posts since Fri, 07 Apr 06 |
Find the difference: Your code: UPDATE kjv SET text_data = REPLACE(text_data, '\', '') My proposal: UPDATE kjv SET text_data = REPLACE(text_data, '\\'', '\'') |
|
Written by gilgal
5 years ago 32 posts since Wed, 12 Dec 07 |
It's not showing any errors but when I check it hasn't corrected. |
|
Written by ansgar
5 years ago 3966 posts since Fri, 07 Apr 06 |
The fact that it doesn't give you any error does not mean it works like you expect it to do. This code works for me in HeidiSQL: select REPLACE('\\\'hi\\\'', '\\\'', '\'') |
|
Written by kalvaro
5 years ago 442 posts since Thu, 29 Nov 07 |
gilgal wrote: It's not showing any errors It won't unless you instruct PHP to display them: ini_set('display_errors', 1); |
|
Please login to leave a reply, or register at first. |