Hi, I am new in this forum and also new to PHP. Atm I am trying to edit a simple comment script. Everything is done already but one last thing left. I want to make a word wrapping in comment text section. I have tried many ways but I have failed. If someone could help me I would be pleased Here are the lines from the script: echo "<div class=\"commentbody\" id=\"$commentrow[0]\">\n I want the text in this div to be wrapped. I have tried to asociate it with this script: $str = "sample text"; echo wordwrap($str,15,"<br />\n",TRUE); But unfortunatelly, it didn't work. I must have done something wrong. Any ideas or suggestions? This is a link of the following free comment script: http://www.zimmertech.com/tutorials/php/25/comment-form-script-tutorial.php Therefore, it has many bugs and this is one of them And the author of the script do not respond anymore.
Also I have just tried using css 3 property: word-wrap: break-word; But this only works in IE. Anyone has any suggestions?
I will copy the whole code to make it clear for all: echo " <link rel=\"stylesheet\" type=\"text/css\" href=\"comments.css\"/> "; $commentquery = mysql_query("SELECT * FROM comments WHERE tutorialid='$tutid' ORDER BY date DESC") or die(mysql_error()); $commentNum = mysql_num_rows($commentquery); echo "<div id=\"currentcomments\" class=\"submitcomment\"><h3 class=\"formtitle\">Comments</h3>\n"; echo "<p class=\"top\">Total: $commentNum (<a href=\"#post\" class=\"link\">comment</a>)</p>\n"; $number = mysql_num_rows($commentquery)+1; while($commentrow = mysql_fetch_row($commentquery)){ $number--; $commentbb = BBCode($commentrow[3]); $commentDate = formatDate($commentrow[4]); echo "<div class=\"commentbody\" id=\"$commentrow[0]\">\n <p>$commentbb</p>\n <p class=\"postedby\">"; if($commentrow[2]){ echo "<b class=\"name\">$commentrow[2]<b class=\"kb\">,</b></b>"; } echo "<b class=\"date\">$commentDate</b> | <b class=\"number\">#$number</b></p>\n \n</div>"; } echo "</div>"; }
The wordwrap should work. Maybe you are working with UTF8 text which one of the comments here mentions: http://dk.php.net/manual/en/function.wordwrap.php#83488