Jump to content

nl2br


wigglesby

Recommended Posts

Hi

 

I have some data in my db, which is inserted into a form.

 

As some of the text is in " it's " with single quote, it inserts with a \' into the db.

 

This is all fine, the problem is I'm wanting to use nl2br, which finds all the \r\n and outputs a break.

 

But this still outputs the it\'s string.

 

I have the following:

 

$json_out = nl2br(stripslashes($mtj->get_json()));

 

But using stripslashes removes the \ form the it\'s but then outputs the rn minus theri slashes.

 

Anyway I can round this?

 

Thanks

Link to comment
Share on other sites

Ok, I'm using:

 

$content = mysql_real_escape_string($_POST['content']);

 

To insert the text.

 

Do I need to add stripslashes before the real_escape_string function?

 

$content = stripslasges(mysql_real_escape_string($_POST['content']));

 

The code:

$json_out = stripslashes(nl2br($mtj->get_json()));

 

didn't work

 

Thanks

Link to comment
Share on other sites

Ok, I'm using:

 

$content = mysql_real_escape_string($_POST['content']);

 

To insert the text.

 

Do I need to add stripslashes before the real_escape_string function?

 

If magic quotes are enabled, yes.

 

if (get_magic_quotes_gpc()) {
  $content = stripslashes($_POST['content']);
} else {
  $content = $_POST['content'];
}
$content = mysql_real_escape_string($content);

Link to comment
Share on other sites

Ok, so it works for some but not others:

 

        if (get_magic_quotes_gpc()) {
                $good_practice = stripslashes($_POST['good_practice']);
                $investment_return = stripslashes($_POST['investment_return']);
        } else {
                $good_practice = $_POST['good_practice'];
                $investment_return = $_POST['investment_return'];
        }
$good_practice = mysql_real_escape_string($_POST['good_practice']);
$investment_return = mysql_real_escape_string($_POST['investment_return']);

 

On output it will still output the following:

 

it\'s

 

Any idea why?

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.