Hi Guys,

I have a problem with posting a news article. I use FCK Editor, and when I enter an article and want to use the apostrophe in a string like this: This is a test article. It can't be done right. The display reads as: This is a test article. It can\'t be done right.

I would like to know how to over come the problem of the backslash appearing in the display.

Also when I want to update the article in this way: It can be done right, can't it?

the display shows this: It can be done right. Can\'t it?

I would like the display to read: It can be done right. Can't it?

Can anyone help me in getting the display to read properly without the backslash appearing

Please find my example code attached.

Member Avatar for diafol

Are you using CKEditor or FCKEditor?

This is due to the automatic addslash.

You can get rid of these with stripslashes(...fckeditor output...) Switch off magic_quotes if you want to stop this (I assume that's why it's happening).

If you use the latest version of PHP, perhaps this will disappear.
Place some apostrophes in 'normal' form fields and see if you get the same result. If you do, it's due to magic quotes.

Howdy ardav, thanks for your suggestion in turning off magic quotes to eradicate the backslash problem I had. It seems to be working ok now, touch wood.
I inserted a piece of code I found into the files I attached and uploaded earlier and so far the backslashes do not appear when adding new articles or updating new articles.

<?php
    if (get_magic_quotes_gpc()) {
        $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);

    while (list($key, $val) = each($process)) {

        foreach ($val as $k => $v) {
            unset($process[$key][$k]);
            if (is_array($v)) {
                $process[$key][stripslashes($k)] = $v;
                $process[] = &$process[$key][stripslashes($k)];
            } else {
                $process[$key][stripslashes($k)] = stripslashes($v);
            }
        }
    }
    unset($process);
}
?>

Thanks for your help

Cheers davBro.

Howdy again ardav,

I forgot to mention I use XAMPP with phpMyAdmin 3.1.3.1.

Cheers, davBro

Member Avatar for diafol

Ok mark as solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.