Jump to content

Archived

This topic is now archived and is closed to further replies.

cohan1279

smilies help...

Recommended Posts

hi i cant seem to get smillies to print. heres the code , any ideas?

function -
[code]function smilies($messagetext){
$path="image"; //Specify the direcory in which images are stored
$sql = "SELECT smilie, image FROM smilies"; //Select the smilies from the database
//along with the names of the image files to
//replace them
$rs = mysql_query($sql); //Run the query
while($row = mysql_fetch_array($rs)) { //Loop through the results creating two arrays
$smilies[] = $row['smilie']; //Create array of smilie texts
$images[] = "<img src='" . $path . "/" . $row['image'] . "'>"; //create array of image replacments with the html in it.
}
$messagetext=str_replace($smilies, $images, $messagetext);//Replace the smilies with the images.
return $messagetext;
}[/code]

and this gets/prints message-
[code]$threadlst = mysql_query("select * from $forumdb where forumid=$forumid and (parentid=$read OR msgid=$read);");
while ($threadlist = mysql_fetch_array($threadlst)) {
$messagetext = eregi_replace("<","&lt;",$threadlist[message]);
$messagetext = eregi_replace("\n","<br>",$messagetext);
$messagetext = eregi_replace("\cM","<br>",$messagetext);
$msgstamp = date("D, F j, Y g:i:s a",$threadlist[timestamp]);
smilies($messagetext);
$clantg = "";
if ($threadlist[clantag] > 0) { $clantga = mysql_fetch_array(mysql_query("select tag from $clandb where num=$threadlist[clantag];")); $clantg = " - $clantga[tag]"; }
if ($threadlist[adminflag] == "2") { $clantg = " - <font class=\"cbad\">Administrator</font>"; }
if (($forumlista[clanonly] == 1) && ($postok[$forumid] >= 2)) {
$deleteok = " - <a href=$config[main]?action=testpage&forumid=$forumid&do_delete=1&post=$threadlist[msgid]>Delete</a>";
}
if ($postok[$forumid] == 3) {
$deleteok = " - <a href=$config[main]?action=testpage&forumid=$forumid&do_delete=1&post=$threadlist[msgid]>Delete</a>";
}

print "<tr><td width=25%><b><i>$threadlist[subject]</b>$deleteok</i></td><td>$threadlist[postername] (#$threadlist[posternum])$clantg</td><td><b>Posted at:</b> $msgstamp</td></tr>\n";
print "<tr><td bgcolor=#993300 colspan=3>&nbsp;</td></tr>\n";
print "<tr><td colspan=3>$messagetext</td></tr>\n";
print "<tr><td colspan=3>&nbsp;</td></tr>\n";
}[/code]
Im not geting any errors its just not printing the smllie pic. am i calling the function right? sorry im still pretty new at this..

the database table is there and has the right info. in it .... im pretty sure its not the problem.

Share this post


Link to post
Share on other sites
ok im gone a dif. route.... now with this [code]$threadlst = mysql_query("select * from $forumdb where forumid=$forumid and (parentid=$read OR msgid=$read);");
while ($threadlist = mysql_fetch_array($threadlst)) {
$messagetext = eregi_replace("<","&lt;",$threadlist[message]);
$messagetext = eregi_replace("\n","<br>",$messagetext);
$messagetext = eregi_replace("\cM","<br>",$messagetext);
$smilies = array( // code => image
            ':)' => 'image/smiley-smile.png',
            ':-)'  =>    "image/smiley-smile.png"      ,

                    ':('    =>    "image/smiley-sad.png"        ,
                    ':-('  =>    "image/smiley-sad.png"       
                    );
    $codes = array_keys($smilies);

    $messagetext = str_replace($codes,$smilies,$messagetext);

    $msgstamp = date("D, F j, Y g:i:s a",$threadlist[timestamp]);

$clantg = "";
if ($threadlist[clantag] > 0) { $clantga = mysql_fetch_array(mysql_query("select tag from $clandb where num=$threadlist[clantag];")); $clantg = " - $clantga[tag]"; }
if ($threadlist[adminflag] == "2") { $clantg = " - <font class=\"cbad\">Administrator</font>"; }
if (($forumlista[clanonly] == 1) && ($postok[$forumid] >= 2)) {
$deleteok = " - <a href=$config[main]?action=testpage&forumid=$forumid&do_delete=1&post=$threadlist[msgid]>Delete</a>";
}
if ($postok[$forumid] == 3) {
$deleteok = " - <a href=$config[main]?action=testpage&forumid=$forumid&do_delete=1&post=$threadlist[msgid]>Delete</a>";
}

print "<tr><td width=25%><b><i>$threadlist[subject]</b>$deleteok</i></td><td>$threadlist[postername] (#$threadlist[posternum])$clantg</td><td><b>Posted at:</b> $msgstamp</td></tr>\n";
print "<tr><td bgcolor=#993300 colspan=3>&nbsp;</td></tr>\n";
print "<tr><td colspan=3>$messagetext</td></tr>\n";
print "<tr><td colspan=3>&nbsp;</td></tr>\n";[/code]

if i try to do a smile ": )" it prints this "image/smiley-smile.png"
im geting closer , but i want to see the pic. ???? any help now?

Share this post


Link to post
Share on other sites
nevermind....... i got it
just need to add <img src=
to

':)' => 'image/smiley-smile.png',
so that its
':)' => '<img src=image/smiley-smile.png',

all working now javascript:void(0);
Grin

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.