Jump to content

Weird Problem


SieRobin

Recommended Posts

[quote author=hackerkts link=topic=102818.msg408669#msg408669 date=1154587597]
I believe he meant
preg_replace("rn", "\n", "words... words and words..");
[/quote]

Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /home/sierobin/public_html/forum.php on line 29

That gives you an error. I still have a question though that wasn't answered.. I really don't understand why this is happening now, since it never has before.
Link to comment
Share on other sites

but replacing rn in a sentence like "he is a stern guy" would make it
"he is a ste
guy"
and i dont think he wants that and use this if you relly want to change rn = \n
[code]
<?php
$text="I love...rnguess whatrnchocolates";
$text=str_replace("rn", "\n", $text);
echo $text;
// Results:-
// I love...
// guess what
// chocolates
?>
[/code]
Link to comment
Share on other sites

Are you performing a [b]stripslashes()[/b] on the reply text before it's added to the database?

If so, that would change "\r\n" to "rn".

Run a [b]str_replace()[/b] or a [b]preg_replace()[/b] instead of stripping slashes, change "\r\n" to "\n", then change "\n" to HTML line breaks, and you should be good to go:

[code=php:0]
$text = nl2br(preg_replace("/\r\n/", "\n", $_POST['text']));
[/code]
Link to comment
Share on other sites

[quote author=Crayon Violent link=topic=102818.msg408918#msg408918 date=1154617461]
is this your own personal forum you are coding or some other script (like ipb, phpbb, etcc) that you are using?
[/quote]

My own personal forum.
Link to comment
Share on other sites

[quote author=HeyRay2 link=topic=102818.msg408929#msg408929 date=1154618751]
Are you performing a [b]stripslashes()[/b] on the reply text before it's added to the database?

If so, that would change "\r\n" to "rn".

Run a [b]str_replace()[/b] or a [b]preg_replace()[/b] instead of stripping slashes, change "\r\n" to "\n", then change "\n" to HTML line breaks, and you should be good to go:

[code=php:0]
$text = nl2br(preg_replace("/\r\n/", "\n", $_POST['text']));
[/code]
[/quote]

I tried this, it didn't work, gave me the same thing without it.
Link to comment
Share on other sites

[quote author=RockingGroudon link=topic=102818.msg408923#msg408923 date=1154617977]
but replacing rn in a sentence like "he is a stern guy" would make it
"he is a ste
guy"
and i dont think he wants that and use this if you relly want to change rn = \n
[code]
<?php
$text="I love...rnguess whatrnchocolates";
$text=str_replace("rn", "\n", $text);
echo $text;
// Results:-
// I love...
// guess what
// chocolates
?>
[/code]
[/quote]

This somewhat works, but I changed \n to [code]<br>[/code]. What's odd is that the \n will not work. I know this because for quoting on my forum I use "\n" to space the text out from the quote. But once it is submitted it doesn't put "\n" it puts rn in replace of that. What's also really odd is that it worked before, it just now decided not to work anymore. The only problem with it, is that if you line break twice, it will only inster ONE line break, not two.
Link to comment
Share on other sites

You didn't answer the question I posed.

Are you performing any modifications on the reply text before it's submitted to the database?

If so, we need to know what those modifications are so we know what state the text is in. Only then will we know what needs to be done to that text to get rid of your "rn" problem.

My code will only work if you have not yet stripped the slashes from your reply text.

Perhaps posting a snippet of your "reply" code would be a step in the right direction.
Link to comment
Share on other sites

[quote author=HeyRay2 link=topic=102818.msg408999#msg408999 date=1154623871]
You didn't answer the question I posed.

Are you performing any modifications on the reply text before it's submitted to the database?

If so, we need to know what those modifications are so we know what state the text is in. Only then will we know what needs to be done to that text to get rid of your "rn" problem.

My code will only work if you have not yet stripped the slashes from your reply text.

Perhaps posting a snippet of your "reply" code would be a step in the right direction.
[/quote]

The script was pretty simple HeyRay2, all it really was, was a $_POST from the textarea on the form. Nothing is modified or even messed around with. It's straight forward posting information into the database.. that's all.
Link to comment
Share on other sites

Glad to hear it started working again.

If you're still interested in investigating why this happened, maybe answer the following:

Have you recently changed anything in your forum code?

Have you switch to a new web host?

Have you upgraded to a new type / version of database?

Have you upgraded to a new version of PHP?


Also, a snippet of your "reply" code could still prove useful in this situation... ;)
Link to comment
Share on other sites

One small question though. For each thread you can view it basically with a title set in the link tag, so when you hold your cursor over the link it shows what was posted so you don't have to click on it to read it. Now if there is quotes or an apostrophe.. it won't display anything past the apostrophe or quote. I tried using, "addslashes" but it really doesn't do anything. How could I make it so you can read the entire thing?
Link to comment
Share on other sites

  • 1 month later...
I'm still having this problem, sure str_replace works good, but what if I wanted to post the word "turn" in? Then I would have a line break at the "rn" in turn.. therefore it doesn't work very well. I thought in PHP when you use a linebreak it's supposed to just output /n?

I don't know, I need some help please, I'd like to have line breaks when you hit the enter button lol.
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.