Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2012
    Posts
    27
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Ban word highlighter

    Hello

    I am having users post offence items in my simple forum I have made and I would like to get banned words from mysql. Could someone finish of my code

    PHP Code:

    <?php
    include 'db.php';


    $str "Its fun to be funny and unfunny";

             
    $sql "select banword_word from banword";
                
    $result mysql_query($sql$conn) or die(mysql_error());
                    while (
    $newArray mysql_fetch_array($result))    {
                        
    $banword_word $newArray['banword_word'];
        
                    }
                    
    $keyword '$banword_word';
    $str preg_replace("/\b([a-z]*${keyword}[a-z]*)\b/i","<b>$1</b>",$str);
    echo 
    "$str"// prints 'Its <b>fun</b> to be <b>funny</b> and <b>unfunny</b>'
    ?>

  2. #2
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Location
    Washington
    Posts
    6,403
    Thanks
    30
    Thanked 877 Times in 875 Posts
    Maybe
    $keyword = $banword_word;

    not
    $keyword = '$banword_word';
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •