Hi,
I'm a pretty hopeless beginner, so take it easy.
ok, I've got PHPNews setup fine and everything works without a hitch. Except that when some joker types in a loooong unbroken string in the comments, it screws up the table width and pretty much breaks the page
After a bit of digging around, I found this code in the comments function of news.php:
/* Get the data for all the Comments */
$com_Query = mysql_query('SELECT time,name,message,email,website FROM ' . $db_prefix . 'comments WHERE mid = ' . $_GET['id'] . ' ORDER by id' . $order . '');
while ($comment = mysql_fetch_array($com_Query))
{
$time = strftime($Settings['shorttimeformat'], $comment['time']);
$message = $comment['message'];
and so on...Now, when you input a comment, it saves it as $message, and there's a template that's used to display the comments by calling up $comment['message']. So I'm guessing that that last line I pasted takes care of all that.
I found some stuff about wordwrap() and basically what I thought I could do is just stick in wordwrap to that last line.
$message = wordwrap($comment['message'], 20, "/n", 1);
But for whatever reason (like I said im very new at this), it just doesn't work and I'm getting a bit disheartened trailing through loads of code without much of a clue
Any help gratefully received
cheers,
mattwell actually there is no easy way around doing the long text string. you can check when they enter the text and just catch it before it gets saved. so count the string using strlen(). if over a certain amount then stop the save and tell them it is too long.
but on your wordwrap you need it to be
$message = wordwrap($comment['message'], 20, "<br />", 1);
you don't want "\n" as that is for like text boxes.
I'm a pretty hopeless beginner, so take it easy.
ok, I've got PHPNews setup fine and everything works without a hitch. Except that when some joker types in a loooong unbroken string in the comments, it screws up the table width and pretty much breaks the page
After a bit of digging around, I found this code in the comments function of news.php:
/* Get the data for all the Comments */
$com_Query = mysql_query('SELECT time,name,message,email,website FROM ' . $db_prefix . 'comments WHERE mid = ' . $_GET['id'] . ' ORDER by id' . $order . '');
while ($comment = mysql_fetch_array($com_Query))
{
$time = strftime($Settings['shorttimeformat'], $comment['time']);
$message = $comment['message'];
and so on...Now, when you input a comment, it saves it as $message, and there's a template that's used to display the comments by calling up $comment['message']. So I'm guessing that that last line I pasted takes care of all that.
I found some stuff about wordwrap() and basically what I thought I could do is just stick in wordwrap to that last line.
$message = wordwrap($comment['message'], 20, "/n", 1);
But for whatever reason (like I said im very new at this), it just doesn't work and I'm getting a bit disheartened trailing through loads of code without much of a clue
Any help gratefully received
cheers,
mattwell actually there is no easy way around doing the long text string. you can check when they enter the text and just catch it before it gets saved. so count the string using strlen(). if over a certain amount then stop the save and tell them it is too long.
but on your wordwrap you need it to be
$message = wordwrap($comment['message'], 20, "<br />", 1);
you don't want "\n" as that is for like text boxes.