jonno946
01-11-2004, 11:18 AM
Hi there,
I am in the process of getting my smilies script working.
I have a table in my database containing both the original smilie (e.g. :P), and what to change it to (e.g. <img src=cheeky.gif>).
I do however, want it to be case insensitive (e.g :P and :p would bring up the same smilie face).
I have checked out the PHP manual and came up with the following, however i am getting unknown modifier errors.
Can anyone spot what could be wrong?
Any help would be much appreciated - its been bugging me so much!
Thanks!
Jonathan
php:
<?php
$str_rep = "SELECT * FROM smilies";
$str_rep_result = mysql_query($str_rep, $db) or die ("Couldn't execute query");
$output = nl2br(htmlentities($post_vars[message]));
$search=$replace=array();
while ($str_rep_row = mysql_fetch_array($str_rep_result)) {
$search[] = '/'.preg_quote($str_rep_row['original']).'/i';
$replace[] = $str_rep_row['change_to'];
}
$output = preg_replace($search, $replace, $output);
echo $output;
?>
I am in the process of getting my smilies script working.
I have a table in my database containing both the original smilie (e.g. :P), and what to change it to (e.g. <img src=cheeky.gif>).
I do however, want it to be case insensitive (e.g :P and :p would bring up the same smilie face).
I have checked out the PHP manual and came up with the following, however i am getting unknown modifier errors.
Can anyone spot what could be wrong?
Any help would be much appreciated - its been bugging me so much!
Thanks!
Jonathan
php:
<?php
$str_rep = "SELECT * FROM smilies";
$str_rep_result = mysql_query($str_rep, $db) or die ("Couldn't execute query");
$output = nl2br(htmlentities($post_vars[message]));
$search=$replace=array();
while ($str_rep_row = mysql_fetch_array($str_rep_result)) {
$search[] = '/'.preg_quote($str_rep_row['original']).'/i';
$replace[] = $str_rep_row['change_to'];
}
$output = preg_replace($search, $replace, $output);
echo $output;
?>