开发者

Remove a bunch of escaped quotes from MYSQL

开发者 https://www.devze.com 2023-01-10 10:13 出处:网络
I have an odd one - I am porting some data from one CMS to another. Both run on LAMP. In the old CMS, the data was stored, with slashes in the DB.

I have an odd one - I am porting some data from one CMS to another. Both run on LAMP.

In the old CMS, the data was stored, with slashes in the DB.

Examples:

Hi. Thanks for looking. It\'s \"awesome\".

That correctly displays when output by the old CMS as:

Hi. Thanks for looking. It's "awesome".

But in the new CMS, they same text is stored simply as the following and they deal with the quotes when it comes out:

Hi. Thanks for looking. It's "awesome".

I have tried replace() directly on mysql, but that just escapes the quote and it just removes all the quotes. Then I tried looking into pulling all the data out with php, and putting it back in, without doing anything hoping that the slashes would escape the data and I'd be good, but not such 开发者_开发百科luck - that seems to work for one of two rows but the query gets broken.

Any ideas? It's been a while since I have played around with add/stripslashes, etc.

Thanks


in PHP you have to make it

$data = stripslashes($data);
$data = mysql_real_escape_string($data);


if you use PHP to import your data you will want to perform -

str_replace("'", "''")

on each entry.

this is how MYSQL escapes strings

0

精彩评论

暂无评论...
验证码 换一张
取 消