FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


preg_replace Problem





Diablosblizz
Hey, I'm trying to make my private messages have smilies on my site. It works if I change the Smile in the message to Smile but no matter what I do I can't get Smile to work.

Heres my code:

Code:
function BBCODE($content){ //define the function of bbcode
$content = nl2br($content); //replaces returns with br's
$match = array(
'#\:)#se'
); //codes used in posts
$replace = array(
"'<img src=\"images/smilies/biggrin.gif\">'"
); //replacements
return preg_replace($match, $replace, $content); //match, and replace
} //end the function


I've tried replacing the : with the HTML special character but it didn't work. I get this error:

Quote:
Warning: preg_replace() [function.preg-replace]: Compilation failed: unmatched parentheses at offset 2 in /home/hotelmar/public_html/admins/inprogress_v1/version6/members/forums/forum2.php on line 20


The way I figure it is that the preg_replace isn't able to find the smile in the text. And sorry about the auto formatting smilies that's not my fault. Razz

Thanks.
Agent ME
Put a backslash in front of the parenthesis.
Diablosblizz
Wow, didn't even think of that. It was 2 AM so I guess it doesn't surprise me. Thank you.
Related topics
Problem with Subdomains
Strange Fire fox problem
Logout problem (Cookie?)
How to solve this problem? Thanks
I have a problem....Mozilla Firefox
post nuke problem
anyone had this phpBB problem?
phpbb problem....
Problem with my password
Pictures problem...
database problem
same problem over here...
Problem with escaping characters in php
Preg replace problem
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.