Hi all,

Iv'e created a PHP/MySQL shoutbox, and like most, the messages are in an <iframe> which is 160px. I want to prevent users from typing in crap such as ssssssssssssssssssssssssssssssssssssssssss which will then cause scrollbars to appear.

I had a look around on PHP.net and came across the wordwrap function, but using the following code as a test:

<?php

$text = "12345678901234567890123456789012345678901234567890123456789012345678901234567890";
$newtext = wordwrap( $text, 20 );

echo "<table width=\"150\" border=\"0\">";
echo "<tr>";
echo "<td>";
echo $newtext;
echo "</td>";
echo "</tr>";
echo "</table>";

?>

Does not work. I want to get it working so that every 20 characters, there is a line break if the 20 characters are all in one word..

TIA

    you need to do your wordwrap like this

    $newtext = wordwrap( $text, 20, "\n", 1);

      Thank you for your reply.

      Here's my new and updated code (Please tell me if it's still incorrect 😃

      $text = "12345678901234567890123456789012345678901234567890
      123456789012345678901234567890";
      $newtext = wordwrap( $text, 20, "\n", 1);
      
      echo "<table width=\"150\" border=\"0\">";
      echo "<tr>";
      echo "<td>";
      echo $newtext;
      echo "</td>";
      echo "</tr>";
      echo "</table>";
      

        well it looks correct, but you are the only one that will be able to
        tell if it worked or not

        OK, well did it???

          hi, i tried to get your shoutbox script, wanted to check it out, so i filled out the form, got the email, but the link doesn't work, so i was unable to download it

            Althought the ShoutBox is pretty much complete, I haven't yet added it to the PHP scripts area yet. I will email you when the script is ready for download 🙂

              Write a Reply...