Jump to content

smilies help...


cohan1279

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.
Link to comment
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?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.