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
https://forums.phpfreaks.com/topic/188316-nl2br/
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
https://forums.phpfreaks.com/topic/188316-nl2br/#findComment-994148
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
https://forums.phpfreaks.com/topic/188316-nl2br/#findComment-994149
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
https://forums.phpfreaks.com/topic/188316-nl2br/#findComment-994164
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.