jamesxg1 Posted March 4, 2009 Share Posted March 4, 2009 <?php function smiley(&$text) { $text = ereg_replace("", "<img src='../simple/template/images/smiley/cheesy.gif'>", $text); $text = ereg_replace(":@", "<img src='../simple/template/images/smiley/angry.gif'>", $text); $text = ereg_replace("", "<img src='../simple/template/images/smiley/cool.gif'>", $text); $text = ereg_replace(":'(", "<img src='../simple/template/images/smiley/cry.gif'>", $text); $text = ereg_replace("", "<img src='../simple/template/images/smiley/embarrassed.gif'>", $text); $text = ereg_replace("", "<img src='../simple/template/images/smiley/grin.gif'>", $text); $text = ereg_replace(":-X", "<img src='../simple/template/images/smiley/lipsrsealed.gif'>", $text); $text = ereg_replace("", "<img src='../simple/template/images/smiley/rolleyes.gif'>", $text); $text = ereg_replace("", "<img src='../simple/template/images/smiley/sad.gif'>", $text); $text = ereg_replace("", "<img src='../simple/template/images/smiley/shocked.gif'>", $text); $text = ereg_replace("", "<img src='../simple/template/images/smiley/smiley.gif'>", $text); $text = ereg_replace("", "<img src='../simple/template/images/smiley/tounge.gif'>", $text); $text = ereg_replace(":\", "<img src='../simple/template/images/smiley/undecided.gif'>", $text); $text = ereg_replace("", "<img src='../simple/template/images/smiley/wink.gif'>", $text); } $line = "test all. . . . . ,:@,,:'(,,,:-X,,,,,,:\."; smiley($line); print "$line"; ?> Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\simple\strn.php on line 16 Many thanks, James. Link to comment https://forums.phpfreaks.com/topic/147858-solved-ereg_replace-error-please-help/ Share on other sites More sharing options...
RussellReal Posted March 4, 2009 Share Posted March 4, 2009 $text = ereg_replace(":\", "<img src='../simple/template/images/smiley/undecided.gif'>", $text); is where your error is you're escaping the closing quote with \ change $text = ereg_replace(":\", "<img src='../simple/template/images/smiley/undecided.gif'>", $text); to $text = ereg_replace(":\\", "<img src='../simple/template/images/smiley/undecided.gif'>", $text); Link to comment https://forums.phpfreaks.com/topic/147858-solved-ereg_replace-error-please-help/#findComment-776043 Share on other sites More sharing options...
jamesxg1 Posted March 4, 2009 Author Share Posted March 4, 2009 $text = ereg_replace(":\", "<img src='../simple/template/images/smiley/undecided.gif'>", $text); is where your error is you're escaping the closing quote with \ change $text = ereg_replace(":\", "<img src='../simple/template/images/smiley/undecided.gif'>", $text); to $text = ereg_replace(":\\", "<img src='../simple/template/images/smiley/undecided.gif'>", $text); ok done , but now i get these errors Warning: ereg_replace() [function.ereg-replace]: REG_EPAREN in C:\xampp\htdocs\simple\strn.php on line 7 Warning: ereg_replace() [function.ereg-replace]: REG_EBRACK in C:\xampp\htdocs\simple\strn.php on line 8 Warning: ereg_replace() [function.ereg-replace]: REG_EPAREN in C:\xampp\htdocs\simple\strn.php on line 12 Warning: ereg_replace() [function.ereg-replace]: REG_EESCAPE in C:\xampp\htdocs\simple\strn.php on line 16 Link to comment https://forums.phpfreaks.com/topic/147858-solved-ereg_replace-error-please-help/#findComment-776045 Share on other sites More sharing options...
RussellReal Posted March 4, 2009 Share Posted March 4, 2009 oh yeah.. regex uses ( ) [ ] / and so forth as special characters which do stuff try putting \ before any occurance of a "special character" Link to comment https://forums.phpfreaks.com/topic/147858-solved-ereg_replace-error-please-help/#findComment-776049 Share on other sites More sharing options...
jamesxg1 Posted March 4, 2009 Author Share Posted March 4, 2009 oh yeah.. regex uses ( ) [ ] / and so forth as special characters which do stuff try putting \ before any occurance of a "special character" worked thanks mate your a (*) cheers Link to comment https://forums.phpfreaks.com/topic/147858-solved-ereg_replace-error-please-help/#findComment-776053 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.