BBcode +function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

bob_the _builder
Forum Contributor
Posts: 131
Joined: Sat Aug 28, 2004 12:25 am

Post by bob_the _builder »

Hi,

Does that mean doing something like:

Code: Select all

function ValidateInput($value) { 

        $BBCode = array( 
        "<b>" => "[b]", 
        "</b>" => "[/b]", 
        "<u>" => "[u]", 
        "</u>" => "[/u]", 
); 
        
        $value = htmlentities($value);
        $value = str_replace(array_keys($BBCode), array_values($BBCode), $value); 
        $value = mysql_real_escape_string(trim(strip_tags($value))); 
        return $value; 
}


adding:

$value = htmlentities($value);

Prior to using string replace on $value?


Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

similar, yes. You'll need to also run your needles through it too (or preprocess them.)
bob_the _builder
Forum Contributor
Posts: 131
Joined: Sat Aug 28, 2004 12:25 am

Post by bob_the _builder »

Hi,

needles?

Does htmlentities() have to be reversed when calling from the database?

Thanks
Last edited by bob_the _builder on Wed Sep 13, 2006 12:46 am, edited 1 time in total.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Like the strpos() function, you are looking for a $needle within $haystack.
bob_the _builder
Forum Contributor
Posts: 131
Joined: Sat Aug 28, 2004 12:25 am

Post by bob_the _builder »

Hi,

Yep just found that .. What exactly am I looking for (matching) in the url?


Thanks
Post Reply