--- Thomas Bolioli <[EMAIL PROTECTED]> wrote: > I am a perl/java/c++ programmer who is doing something in php and > have > run accross something I am stumped with. I am trying to replace > carriage > returns with <br> or <p> tags (p's in groups of two and br's for > any > unmatched cr's). I have tried all of the *_replace() functions > including > string_*, ereg_* and preg_*. None have worked the way they seem to > should. Note, I am a perl programmer and preg_replace() did not > work > while a test perl script did. I have tried multiple forms of > patterns > from "\r\n" to "\n" to "\r" to "/\r?\n/ei" (in the *reg_* > functions). I > even took code verbatim from examples in the docs to no avail. I > have > included the entire block of code (and mysql_dump output) since > there is > something I have apparently not done right and it may not be in the > > pattern matches. > Thanks in advance, > Tom > > > *The offending code:* > > }elseif($_REQUEST['add']){ > $desc = $_REQUEST['description']; > str_replace("\r\n\r\n", "<p>", $desc); > str_replace("\r\n", "<br>", $desc);
I believe you need to assign this to something. So your lines would look more like: $desc=str_replace("\r\n\r\n", "<p>", $desc); $desc=str_replace("\r\n", "<br>", $desc); > $result = mysql_query('INSERT INTO hr_listings > (title,description,location,end_date,posting_date) > VALUES("'.$_REQUEST['title'].'","'.$desc.'","'.$_REQUEST['location'].'","'.$_REQUEST['end_date'].'", > > NOW())',$db) > or trigger_error("MySQL error nr ".mysql_errno().": > ".mysql_error()); > > > *Output of mysql_dump showing the \r\n's going in* > INSERT INTO hr_listings VALUES > (15,'test',5,'2003-06-16','2003-09-11',NULL,'This > is one line\r\nThis is the next\r\n\r\nThis is another > paragraph\r\n\r\n'); > INSERT INTO hr_listings VALUES > (16,'test2',1,'2003-06-16','2004-09-11',NULL,'Thi > s is one line\r\nThis is the next\r\n\r\nThis is another > paragraph\r\n\r\n'); > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > ===== Mark Weinstock [EMAIL PROTECTED] *************************************** You can't demand something as a "right" unless you are willing to fight to death to defend everyone else's right to the same thing. *************************************** __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php