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
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,285
    Thanks
    23
    Thanked 611 Times in 610 Posts
    Maybe
    $keyword = $banword_word;

    not
    $keyword = '$banword_word';
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."


  •  

    Posting Permissions

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