Ok, I'm trying the usual smilies replace function (and I am trying it from scratch so I learn more rather then just getting a code snippet somewhere) and I'm having trouble with it.
My database has the the following fields: id, code, image. The code is the the part they type to get a smilie and the image is just that, the .gif name of the image
Here is the function I have:
function display_smilies($text)
{
global $config;
//get smilies code from db
$query = sql_query( "SELECT * FROM table_smilies" );
while ( $smilies = sql_fetch_array($query) )
{
$search = $smilies["code"];
$replace = "<img src=\"/images/smilies/{$smilies["image"]}\">";
$text = preg_replace($search, $replace, $text);
echo "<br>code is: $search, pic: $replace";
}
return $text;
}
Now , I put in that echo statement at the end there to see what was going on, the code gets displayed properky and the actual smilie image gets displayed behind it, so all seems to be working ok. However I gets tons of errors pointing to the function file on the line number that contains the preg_replace command
Warning: No ending delimiter ';' found in
Warning: No ending delimiter ':' found in
Warning: Compilation failed: nothing to repeat at offset 0 in
And for those that have code of 8), I get
Warning: Delimiter must not be alphanumeric or backslash in