Jump to content


Photo

smilies help...


  • Please log in to reply
2 replies to this topic

#1 cohan1279

cohan1279
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 28 October 2006 - 09:56 PM

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

function -
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;
}

and this gets/prints message-
$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";
}
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.

#2 cohan1279

cohan1279
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 28 October 2006 - 10:44 PM

ok im gone a dif. route.... now with this
$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";

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?

#3 cohan1279

cohan1279
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 28 October 2006 - 10:57 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users