Jaehoon Posted March 30, 2010 Share Posted March 30, 2010 Hey guys, I have a form I'm submitting via POST and I have no idea how to replace the enter spaces in my textarea into a <br>. I've been trying all of these: $message = ereg_replace("=0D=0A=", "\r", $message); $message = ereg_replace("=0D=0A=", "<br>", $message); But nothing is working, does anyone know how to accomplish this? Thanks in advance! Quote Link to comment Share on other sites More sharing options...
runnerjp Posted March 30, 2010 Share Posted March 30, 2010 /* This will work. */ $letter = '<br />'; $string = $message $string = ereg_replace("=0D=0A="', $letter, $string); echo $string; /* Output: */ Quote Link to comment Share on other sites More sharing options...
Jaehoon Posted March 30, 2010 Author Share Posted March 30, 2010 Getting an error: Parse error: syntax error, unexpected T_VARIABLE in I replaced/added/delete the single single quote after the 0a0d and still cant get the error to go away Quote Link to comment Share on other sites More sharing options...
runnerjp Posted March 30, 2010 Share Posted March 30, 2010 /* This will work. */ $letter = '<br />'; $string = $message $string = ereg_replace('=0D=0A=', $letter, $string); echo $string; /* Output: */ Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted March 30, 2010 Share Posted March 30, 2010 After you fix the parse error it will work /* This will work. */ $letter = '<br />'; $string = $message; //missing semicolon $string = ereg_replace('=0D=0A=', $letter, $string); echo $string; /* Output: */ Quote Link to comment Share on other sites More sharing options...
Jaehoon Posted March 30, 2010 Author Share Posted March 30, 2010 Thanks for your help, the code you posted works, but I seem to be capturing the "ENTER" put in by php into the url wrong... URL: msg=this%0D%0Ais%0D%0Aa%0D%0Atest in the url a ENTER break is represented as %0D%0A , is '=0D=0A=' the proper way to represent the %0D%0A in the replace function? Quote Link to comment Share on other sites More sharing options...
runnerjp Posted March 30, 2010 Share Posted March 30, 2010 are you trying to get rid of spaces in a url... if so just strip it...is this correct?? Quote Link to comment Share on other sites More sharing options...
Jaehoon Posted March 30, 2010 Author Share Posted March 30, 2010 No sorry, this is a screenshot of my script... I wanted to represent my blog post as shown on the textarea... Just like the box I'm typing the reply on right now, if i press enter to goto the next line... on the forum it will show up as a break So I guess the main issue is that when I submit my form... my breaks are stripped out, and everything becomes 1 long sentence. I wanted my break to remain so the blog post can be represented with breaks the way it was written into the textarea box I know this problem can be avoided if i type <br> into my textarea to goto the next line, but I wanted to be able to press enter to insert a break automatically Quote Link to comment Share on other sites More sharing options...
runnerjp Posted March 30, 2010 Share Posted March 30, 2010 any chnace you could paste in ur code? Quote Link to comment Share on other sites More sharing options...
ignace Posted March 30, 2010 Share Posted March 30, 2010 LOL 0D0A is the equivalent of \n for which their is a function called nl2br Quote Link to comment Share on other sites More sharing options...
runnerjp Posted March 30, 2010 Share Posted March 30, 2010 yer i was thinking of nl2br() nl2br($message) but if he is sticking the whole message in the url thats not great... was looking to see if anything was added to db ect Quote Link to comment Share on other sites More sharing options...
Jaehoon Posted March 30, 2010 Author Share Posted March 30, 2010 Thanks.. I just found the article @ http://www.plus2net.com/php_tutorial/line-breaks.php I've only been using php for a week, so yeah lol. I am using a mySQL database to store all my data, but I post the form and caught the message with $_GET... Is there a better way to go about this? Quote Link to comment Share on other sites More sharing options...
runnerjp Posted March 30, 2010 Share Posted March 30, 2010 ok hummm... so are you wanting to display the post results? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.