MySQL Forums
Forum List  »  PHP

Re: PHP + Smilies
Posted by: William Dalladay-Morgan
Date: February 02, 2006 07:34PM

Well... so far my results are that the smilie tag gets replaced with <img src="" alt="" />

the function goes like this:

function doSmilies($data)
{
$smilie_regex = array();
$smilie_replace = array();

$sql = "SELECT smilie_id,smilie_tag,smilie_img,smilie_alt FROM content_smilies ORDER BY smilie_id ASC";
$q = mysql_query($sql,$this->getConn());

while($r = mysql_fetch_array($q)) {
array_push($smilie_regex,'/'. $r['smilie_tag'] .'/s');
array_push($smilie_replace,'<img src="'. $smilie_img .'" alt="'. $smilie_alt .'" />');
}

ksort($smilie_regex);
ksort($smilie_replace);
$data = preg_replace($smilie_regex,$smilie_replace,$data);

return $data;
}

Any reason whys its not putting the image login and alt text in the image replacement?

Thanks

slowmo wrote:
> Simple solution would be to run through all the
> records in content_smilies and search for tags in
> $data. If it is found, do a replacement.
> One way or another, you will have to cycle through
> all the smileys to do a replacement.
>
>
>
> Edited 1 times. Last edit at 02/02/06 07:30PM by
> slowmo.

Many Thanks,
~ Wills

Options: ReplyQuote


Subject
Written By
Posted
February 02, 2006 10:31AM
February 02, 2006 06:30PM
Re: PHP + Smilies
February 02, 2006 07:34PM
February 02, 2006 07:37PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.