ashton Posted July 28, 2006 Share Posted July 28, 2006 Alright I have forums, that Were independently desined meaning there not like phpbb etc. there just forums programmed in PHP. I would like to add smiles to the forums does anyone know the best way to do that? Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/ Share on other sites More sharing options...
wildteen88 Posted July 28, 2006 Share Posted July 28, 2006 This [url=http://ryanslife.net/2006/07/12/php-simple-emoticon-support/]site teaces[/url] you how to create a smilie parser. Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65240 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 Alright I tried to use that site I made Funttion and everything, But now its getting errors and is changing crazy on me, I put this in.[code]<?php // defines the emoticons $emoticonarray = array( ':)' => 'smile.gif', ':King:' => 'king.gif', ':*' => 'kiss.gif' ':lol:' => 'lol.gif', ':loser:' => 'loser.gif', ':money:' => 'moneybag.gif' ':muscle:' => 'muscle.gif', ':no:' => 'no.gif', ':nono:' => 'nono.gif' ':offwall:' => 'offwall.gif', ':ohboy:' => 'ohboy.gif', ':pc:' => 'pc.gif' ':please:' => 'please.gif', ':rofl:' => 'rofl.gif', ':roll:' => 'rolleyes.gif' // generates the search and replace arrays foreach($emoticonarray as $emoticon => $img) { $search[] = $emoticon; $replace[] = '<img src="/emoticons/' . $img . '" alt="' . $emoticon . '" />'; } // searches the text passed to the function $text = str_ireplace($search, $replace, $text); // return the value return $text;[/code]Then once I save it and view it again it turns into this[code]<?php // defines the emoticons $emoticonarray = array( ':)' => 'smile.gif', ':King:' => 'king.gif', ':*' => 'kiss.gif' ':lol:' => 'lol.gif', ':loser:' => 'loser.gif', ':money:' => 'moneybag.gif' ':muscle:' => 'muscle.gif', ':no:' => 'no.gif', ':nono:' => 'nono.gif' ':offwall:' => 'offwall.gif', ':ohboy:' => 'ohboy.gif', ':pc:' => 'pc.gif' ':please:' => 'please.gif', ':rofl:' => 'rofl.gif', ':roll:' => 'rolleyes.gif' // generates the search and replace arrays foreach($emoticonarray as $emoticon => $img) { $search[] = $emoticon; $replace[] = '<img src="/emoticons/' . $img . '" alt="' . $emoticon . '" />'; } // searches the text passed to the function $text = str_ireplace($search, $replace, $text); // return the value return $text;[/code]And its giving me this error:Parse error: parse error, unexpected ':', expecting ')' in /home/spyderw/public_html/mf/functions.php on line 4Thats just problem 1, The guide says to " You pull the data from your database and assign it to the variable $comment. All you would have to do the replace the text-based emoticons with the images that you have set up is as follows:<?phpecho emoticon($comment);?> "Can you explain that?Please help me It would be most appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65275 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 See it even turned into it on the codes!! Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65276 Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 This doesn't even look to me like it will work, what the hell kind of format is this.[code]‘:)’ => ’smile.gif’,[/code]They are all still url encoded, I don't see why they would need to be like that when displaying them. If you want to show emoticons, it's simpleget the pictures for the emoticon, or make them in photoshop.Now name them what they are, if it's a smileygif's are better for this specific task sosmiley.gifwhatevernow save that in a variablesmiley.gifsmiley = "smiley.gif";but make sure it's leading to the path of the picture.wherever you want it to appearuse<img src="<?php echo $smiley; ?>" />that should print out the pictureor you can dynamically use it from the databasesimply put in the url of the picture in the databaseand then call it from the databaseand do the same thingif you have the db array stored in $row again just use<img src="<?php echo $row['smiley']; ?> />or something like that. It's pretty simple, you can set it up any number of ways if you so desired. Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65283 Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 I don't see how ,but there using shell comment tags, remove the comments, clean it up some, if you are using that anyway, atleast clean it some so we can view it, so I can understand what everything is doing Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65285 Share on other sites More sharing options...
wildteen88 Posted July 28, 2006 Share Posted July 28, 2006 The codes fine, its becuase of the site is using the incorrect quotes instead of ‘ it is supposed to be ' and the same applies to ” which is supposed to be "I have changed you code above and it should now work. This should now work:[code]<?php // defines the emoticons $emoticonarray = array( ':)' => 'smile.gif', ':King:' => 'king.gif', ':*' => 'kiss.gif', ':lol:' => 'lol.gif', ':loser:' => 'loser.gif', ':money:' => 'moneybag.gif', ':muscle:' => 'muscle.gif', ':no:' => 'no.gif', ':nono:' => 'nono.gif', ':offwall:' => 'offwall.gif', ':ohboy:' => 'ohboy.gif', ':pc:' => 'pc.gif', ':please:' => 'please.gif', ':rofl:' => 'rofl.gif', ':roll:' => 'rolleyes.gif'); // generates the search and replace arrays foreach($emoticonarray as $emoticon => $img) { $search[] = $emoticon; $replace[] = '<img src="/emoticons/' . $img . '" alt="' . $emoticon . '" />'; } // searches the text passed to the function $text = str_ireplace($search, $replace, $text); // return the value return $text; ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65308 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 Ok I fixed up the code now its,[code]<?php // defines the emoticons $emoticonarray = array( ":)" => "smile.gif", ":King:" => "king.gif", ":*" => "kiss.gif" ":lol:" => "lol.gif", ":loser:" => "loser.gif", ":money:" => "moneybag.gif" ":muscle:" => "muscle.gif", ":no:" => "no.gif", ":nono:" => "nono.gif" ":offwall:" => "offwall.gif", ":ohboy:" => "ohboy.gif", ":pc:" => "pc.gif" ":please:" => "please.gif", ":rofl:" => "rofl.gif", ":roll:" => "rolleyes.gif" // generates the search and replace arrays foreach($emoticonarray as $emoticon => $img) { $search[] = $emoticon; $replace[] = "<img src="/emoticons/" . $img . "" alt="" . $emoticon . "" />"; } // searches the text passed to the function $text = str_ireplace($search, $replace, $text); // return the value return $text;?>[/code]But now im confused first is that correct and now what do I do In order to have the smiles show up on my forums. So im using the guide from http://ryanslife.net/2006/07/12/php-simple-emoticon-support/ Just to show you what im looking at can anyone help me here? Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65310 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 OK thank you wild, Alright now that I got your code down now what do I do (when it comes to editing it for server information etc.) Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65311 Share on other sites More sharing options...
wildteen88 Posted July 28, 2006 Share Posted July 28, 2006 In order for that code you'll need to create a function for it, call it smilies. Then when you goto use it you use $str = smilies($str);Which will convert any smilie code within the variable $str, $str can be any variable.You'll have to place this code within the file that displays your forum messages. And wrap your smilies function around the variable that holds the message. Prehaps if you ask the developer that created the forum for you may be able to help with that. Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65314 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 this is the function <?php // defines the emoticons $emoticonarray = array( ‘:)’ => ’smile.gif’, ‘:King:’ => ’king.gif’, ‘:*’ => ‘kiss.gif’ ‘:lol:’ => ’lol.gif’, ‘:loser:’ => ’loser.gif’, ‘:money:’ => ‘moneybag.gif’ ‘:muscle:’ => ’muscle.gif’, ‘:no:’ => ’no.gif’, ‘:nono:’ => ‘nono.gif’ ‘:offwall:’ => ’offwall.gif’, ‘:ohboy:’ => ’ohboy.gif’, ‘:pc:’ => ‘pc.gif’ ‘:please:’ => ’please.gif’, ‘:rofl:’ => ’rofl.gif’, ‘:roll:’ => ‘rolleyes.gif’ // generates the search and replace arrays foreach($emoticonarray as $emoticon => $img) { $search[] = $emoticon; $replace[] = ‘<img src=”/emoticons/’ . $img . ‘” alt=”‘ . $emoticon . ‘” />’; } // searches the text passed to the function $text = str_ireplace($search, $replace, $text); // return the value return $text;?>Do I need to edit anything in there? Or just put the $str = smilies($str);were I want it to show up and it will work? Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65338 Share on other sites More sharing options...
wildteen88 Posted July 28, 2006 Share Posted July 28, 2006 That cade isnt a function yet as you havent defined it. In order for it be a function you do this:[code]function function_name() { // code for function}[/code]So this is what its supposed to be:[code]function smilies($text) { // defines the emoticons $emoticonarray = array( ":)" => "smile.gif", ":King:" => "king.gif", ":*" => "kiss.gif" ":lol:" => "lol.gif", ":loser:" => "loser.gif", ":money:" => "moneybag.gif" ":muscle:" => "muscle.gif", ":no:" => "no.gif", ":nono:" => "nono.gif" ":offwall:" => "offwall.gif", ":ohboy:" => "ohboy.gif", ":pc:" => "pc.gif" ":please:" => "please.gif", ":rofl:" => "rofl.gif", ":roll:" => "rolleyes.gif" // generates the search and replace arrays foreach($emoticonarray as $emoticon => $img) { $search[] = $emoticon; $replace[] = "<img src="/emoticons/" . $img . "" alt="" . $emoticon . "" />"; } // searches the text passed to the function $text = str_ireplace($search, $replace, $text); // return the value return $text;}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65346 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 Alright I put that up now my question is were do I put, $str = smilies($str);And how do I tell my forums to make the specified text into other smilies? Like were would I put a script at in the Forums php script file or in the db somewerE? Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65368 Share on other sites More sharing options...
wildteen88 Posted July 28, 2006 Share Posted July 28, 2006 Wherer you put the code I have no idea, as I dont know what your forum code is. So its impossible for me to tell the exact location. This is why I recommend you to contact the developer of the script which might be able to help.Also you dont use this code exactly:[code]$str = smilies($str);[/code]You'll need to change $str to the variable your script uses to hold the forums message. Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65374 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 Alright well if you have AIM im me AshtonhyAnd I know were the forum code is however how would I find out what the variable is? Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65384 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 the databases name is forum so would the variable just be $forum ?? Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65387 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 And do I put $str = smilies($str); that were the forum scripts are? Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65390 Share on other sites More sharing options...
wildteen88 Posted July 28, 2006 Share Posted July 28, 2006 You cannot just put $str = smilies($str); anywhere and expect it to work. If you zip your forum code up and provide a link to download it and I'll see if I can see where it'll need to be placed. At the moment I cannot tell where it'll need to placed as I need to see the code in order to know that. Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65391 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 [code][code]This is my code for Smilies.php (function)[code]function smilies($forum) { // defines the emoticons $emoticonarray = array( ":)" => "smile.gif", ":King:" => "king.gif", ":*" => "kiss.gif" ":lol:" => "lol.gif", ":loser:" => "loser.gif", ":money:" => "moneybag.gif" ":muscle:" => "muscle.gif", ":no:" => "no.gif", ":nono:" => "nono.gif" ":offwall:" => "offwall.gif", ":ohboy:" => "ohboy.gif", ":pc:" => "pc.gif" ":please:" => "please.gif", ":rofl:" => "rofl.gif", ":roll:" => "rolleyes.gif" // generates the search and replace arrays foreach($emoticonarray as $emoticon => $img) { $search[] = $emoticon; $replace[] = "<img src="emoticons/" . $img . "" alt="" . $emoticon . "" />"; } // searches the text passed to the function $text = str_ireplace($search, $replace, $text); // return the value return $forum;}[/code]These are my forum codes:[code]<?php // forum.php :: Internal forums script for the game.include('lib.php');include('cookies.php');$link = opendb();$userrow = checkcookies();if ($userrow == false) { display("The forum is for registered players only.", "Forum"); die(); }$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");$controlrow = mysql_fetch_array($controlquery);// Close game.if ($controlrow["gameopen"] == 0) { display("The game is currently closed for maintanence. Please check back later.","Game Closed"); die(); }// Force verify if the user isn't verified yet.if ($controlrow["verifyemail"] == 1 && $userrow["verify"] != 1) { header("Location: users.php?do=verify"); die(); }// Block user if he/she has been banned.if ($userrow["authlevel"] == 2) { die("Your account has been blocked. Please try back later."); }if (isset($_GET["do"])) { $do = explode(":",$_GET["do"]); if ($do[0] == "thread") { showthread($do[1], $do[2]); } elseif ($do[0] == "new") { newthread(); } elseif ($do[0] == "reply") { reply(); } elseif ($do[0] == "list") { donothing($do[1]); } } else { donothing(0); }function donothing($start=0) { $query = doquery("SELECT * FROM {{table}} WHERE parent='0' ORDER BY newpostdate DESC LIMIT 50", "forum"); $page = "<table width=\"100%\"><tr><td style=\"padding:1px; background-color:black;\"><table width=\"100%\" style=\"margins:0px;\" cellspacing=\"1\" cellpadding=\"3\"><tr><th colspan=\"3\" style=\"background-color:#dddddd;\"><center><a href=\"forum.php?do=new\">New Thread</a></center></th></tr><tr><th width=\"50%\" style=\"background-color:#dddddd;\">Thread</th><th width=\"10%\" style=\"background-color:#dddddd;\">Replies</th><th style=\"background-color:#dddddd;\">Last Post</th></tr>\n"; $count = 1; if (mysql_num_rows($query) == 0) { $page .= "<tr><td style=\"background-color:#ffffff;\" colspan=\"3\"><b>No threads in forum.</b></td></tr>\n"; } else { while ($row = mysql_fetch_array($query)) { if ($count == 1) { $page .= "<tr><td style=\"background-color:#ffffff;\"><a href=\"forum.php?do=thread:".$row["id"].":0\">".$row["title"]."</a></td><td style=\"background-color:#ffffff;\">".$row["replies"]."</td><td style=\"background-color:#ffffff;\">".$row["newpostdate"]."</td></tr>\n"; $count = 2; } else { $page .= "<tr><td style=\"background-color:#eeeeee;\"><a href=\"forum.php?do=thread:".$row["id"].":0\">".$row["title"]."</a></td><td style=\"background-color:#eeeeee;\">".$row["replies"]."</td><td style=\"background-color:#eeeeee;\">".$row["newpostdate"]."</td></tr>\n"; $count = 1; } } } $page .= "</table></td></tr></table>"; display($page, "Forum"); }function showthread($id, $start) { $query = doquery("SELECT * FROM {{table}} WHERE id='$id' OR parent='$id' ORDER BY id LIMIT $start,100", "forum"); $query2 = doquery("SELECT title FROM {{table}} WHERE id='$id' LIMIT 1", "forum"); $row2 = mysql_fetch_array($query2); $page = "<table width=\"100%\"><tr><td style=\"padding:1px; background-color:black;\"><table width=\"100%\" style=\"margins:0px;\" cellspacing=\"1\" cellpadding=\"3\"><tr><td colspan=\"2\" style=\"background-color:#dddddd;\"><b><a href=\"forum.php\">Forum</a> :: ".$row2["title"]."</b></td></tr>\n"; $count = 1; while ($row = mysql_fetch_array($query)) { if ($count == 1) { $page .= "<tr><td width=\"25%\" style=\"background-color:#ffffff; vertical-align:top;\"><span class=\"small\"><b>".$row["author"]."</b><br /><br />".prettyforumdate($row["postdate"])."</td><td style=\"background-color:#ffffff; vertical-align:top;\">".nl2br($row["content"])."</td></tr>\n"; $count = 2; } else { $page .= "<tr><td width=\"25%\" style=\"background-color:#eeeeee; vertical-align:top;\"><span class=\"small\"><b>".$row["author"]."</b><br /><br />".prettyforumdate($row["postdate"])."</td><td style=\"background-color:#eeeeee; vertical-align:top;\">".nl2br($row["content"])."</td></tr>\n"; $count = 1; } } $page .= "</table></td></tr></table><br />"; $page .= "<table width=\"100%\"><tr><td><b>Reply To This Thread:</b><br /><form action=\"forum.php?do=reply\" method=\"post\"><input type=\"hidden\" name=\"parent\" value=\"$id\" /><input type=\"hidden\" name=\"title\" value=\"Re: ".$row2["title"]."\" /><textarea name=\"content\" rows=\"7\" cols=\"40\"></textarea><br /><input type=\"submit\" name=\"submit\" value=\"Submit\" /> <input type=\"reset\" name=\"reset\" value=\"Reset\" /></form></td></tr></table>"; display($page, "Forum"); }function reply() { global $userrow; extract($_POST); $query = doquery("INSERT INTO {{table}} SET id='',postdate=NOW(),newpostdate=NOW(),author='".$userrow["charname"]."',parent='$parent',replies='0',title='$title',content='$content'", "forum"); $query2 = doquery("UPDATE {{table}} SET newpostdate=NOW(),replies=replies+1 WHERE id='$parent' LIMIT 1", "forum"); header("Location: forum.php?do=thread:$parent:0"); die(); }function newthread() { global $userrow; if (isset($_POST["submit"])) { extract($_POST); $query = doquery("INSERT INTO {{table}} SET id='',postdate=NOW(),newpostdate=NOW(),author='".$userrow["charname"]."',parent='0',replies='0',title='$title',content='$content'", "forum"); header("Location: forum.php"); die(); } $page = "<table width=\"100%\"><tr><td><b>Make A New Post:</b><br /><br/ ><form action=\"forum.php?do=new\" method=\"post\">Title:<br /><input type=\"text\" name=\"title\" size=\"50\" maxlength=\"50\" /><br /><br />Message:<br /><textarea name=\"content\" rows=\"7\" cols=\"40\"></textarea><br /><br /><input type=\"submit\" name=\"submit\" value=\"Submit\" /> <input type=\"reset\" name=\"reset\" value=\"Reset\" /></form></td></tr></table>"; display($page, "Forum"); } ?>[/code]Any Ideas what to do, I got a folder names emoticons with all the smilies in it as well and thats whats set up what should I do now?[/code][/code] Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65392 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 Any more information you need? :-/Im sorry to have botherd you so much. Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65393 Share on other sites More sharing options...
wildteen88 Posted July 28, 2006 Share Posted July 28, 2006 Okay. place your smiles function code before this line:[code]function showthread($id, $start) {[/code]Now change this:[code]if ($count == 1) { $page .= "<tr><td width=\"25%\" style=\"background-color:#ffffff; vertical-align:top;\"><span class=\"small\"><b>".$row["author"]."</b><br /><br />".prettyforumdate($row["postdate"])."</td><td style=\"background-color:#ffffff; vertical-align:top;\">".nl2br($row["content"])."</td></tr>\n"; $count = 2; } else { $page .= "<tr><td width=\"25%\" style=\"background-color:#eeeeee; vertical-align:top;\"><span class=\"small\"><b>".$row["author"]."</b><br /><br />".prettyforumdate($row["postdate"])."</td><td style=\"background-color:#eeeeee; vertical-align:top;\">".nl2br($row["content"])."</td></tr>\n"; $count = 1; }[/code]to this:[code]if ($count == 1) { $page .= "<tr><td width=\"25%\" style=\"background-color:#ffffff; vertical-align:top;\"><span class=\"small\"><b>".$row["author"]."</b><br /><br />".prettyforumdate($row["postdate"])."</td><td style=\"background-color:#ffffff; vertical-align:top;\">".nl2br(smilies($row["content"]))."</td></tr>\n"; $count = 2; } else { $page .= "<tr><td width=\"25%\" style=\"background-color:#eeeeee; vertical-align:top;\"><span class=\"small\"><b>".$row["author"]."</b><br /><br />".prettyforumdate($row["postdate"])."</td><td style=\"background-color:#eeeeee; vertical-align:top;\">".nl2br(smilies($row["content"]))."</td></tr>\n"; $count = 1; }[/code]It should now parse any smilie code. Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65399 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 Ok this is what I tried to do, this is my smilie function code, that is saved as Smilies.php.[code]<?php$dbh=mysql_connect ("localhost", "spyderw_Ashton", "ashton2004596") or die ('I cannot connect to the database because: ' . mysql_error());mysql_select_db ("spyderw_dk");function smilies($forum) { // defines the emoticons $emoticonarray = array( ":)" => "smile.gif", ":King:" => "king.gif", ":*" => "kiss.gif" ":lol:" => "lol.gif", ":loser:" => "loser.gif", ":money:" => "moneybag.gif" ":muscle:" => "muscle.gif", ":no:" => "no.gif", ":nono:" => "nono.gif" ":offwall:" => "offwall.gif", ":ohboy:" => "ohboy.gif", ":pc:" => "pc.gif" ":please:" => "please.gif", ":rofl:" => "rofl.gif", ":roll:" => "rolleyes.gif" // generates the search and replace arrays foreach($emoticonarray as $emoticon => $img) { $search[] = $emoticon; $replace[] = "<img src="emoticons/" . $img . "" alt="" . $emoticon . "" />"; } // searches the text passed to the function $text = str_ireplace($search, $replace, $text); // return the value return $forum;}function showthread($id, $start) { [/code]And this is my forums code as you told me to do, saved as forums.php.[code]<?php // forum.php :: Internal forums script for the game.include('lib.php');include('cookies.php');$link = opendb();$userrow = checkcookies();if ($userrow == false) { display("The forum is for registered players only.", "Forum"); die(); }$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");$controlrow = mysql_fetch_array($controlquery);// Close game.if ($controlrow["gameopen"] == 0) { display("The game is currently closed for maintanence. Please check back later.","Game Closed"); die(); }// Force verify if the user isn't verified yet.if ($controlrow["verifyemail"] == 1 && $userrow["verify"] != 1) { header("Location: users.php?do=verify"); die(); }// Block user if he/she has been banned.if ($userrow["authlevel"] == 2) { die("Your account has been blocked. Please try back later."); }if (isset($_GET["do"])) { $do = explode(":",$_GET["do"]); if ($do[0] == "thread") { showthread($do[1], $do[2]); } elseif ($do[0] == "new") { newthread(); } elseif ($do[0] == "reply") { reply(); } elseif ($do[0] == "list") { donothing($do[1]); } } else { donothing(0); }function donothing($start=0) { $query = doquery("SELECT * FROM {{table}} WHERE parent='0' ORDER BY newpostdate DESC LIMIT 50", "forum"); $page = "<table width=\"100%\"><tr><td style=\"padding:1px; background-color:black;\"><table width=\"100%\" style=\"margins:0px;\" cellspacing=\"1\" cellpadding=\"3\"><tr><th colspan=\"3\" style=\"background-color:#dddddd;\"><center><a href=\"forum.php?do=new\">New Thread</a></center></th></tr><tr><th width=\"50%\" style=\"background-color:#dddddd;\">Thread</th><th width=\"10%\" style=\"background-color:#dddddd;\">Replies</th><th style=\"background-color:#dddddd;\">Last Post</th></tr>\n"; $count = 1; if (mysql_num_rows($query) == 0) { $page .= "<tr><td style=\"background-color:#ffffff;\" colspan=\"3\"><b>No threads in forum.</b></td></tr>\n"; } else { while ($row = mysql_fetch_array($query)) { if ($count == 1) { $page .= "<tr><td style=\"background-color:#ffffff;\"><a href=\"forum.php?do=thread:".$row["id"].":0\">".$row["title"]."</a></td><td style=\"background-color:#ffffff;\">".$row["replies"]."</td><td style=\"background-color:#ffffff;\">".$row["newpostdate"]."</td></tr>\n"; $count = 2; } else { $page .= "<tr><td style=\"background-color:#eeeeee;\"><a href=\"forum.php?do=thread:".$row["id"].":0\">".$row["title"]."</a></td><td style=\"background-color:#eeeeee;\">".$row["replies"]."</td><td style=\"background-color:#eeeeee;\">".$row["newpostdate"]."</td></tr>\n"; $count = 1; } } } $page .= "</table></td></tr></table>"; display($page, "Forum"); }function showthread($id, $start) { $query = doquery("SELECT * FROM {{table}} WHERE id='$id' OR parent='$id' ORDER BY id LIMIT $start,100", "forum"); $query2 = doquery("SELECT title FROM {{table}} WHERE id='$id' LIMIT 1", "forum"); $row2 = mysql_fetch_array($query2); $page = "<table width=\"100%\"><tr><td style=\"padding:1px; background-color:black;\"><table width=\"100%\" style=\"margins:0px;\" cellspacing=\"1\" cellpadding=\"3\"><tr><td colspan=\"2\" style=\"background-color:#dddddd;\"><b><a href=\"forum.php\">Forum</a> :: ".$row2["title"]."</b></td></tr>\n"; $count = 1; while ($row = mysql_fetch_array($query)) { if ($count == 1) { $page .= "<tr><td width=\"25%\" style=\"background-color:#ffffff; vertical-align:top;\"><span class=\"small\"><b>".$row["author"]."</b><br /><br />".prettyforumdate($row["postdate"])."</td><td style=\"background-color:#ffffff; vertical-align:top;\">".nl2br(smilies($row["content"]))."</td></tr>\n"; $count = 2; } else { $page .= "<tr><td width=\"25%\" style=\"background-color:#eeeeee; vertical-align:top;\"><span class=\"small\"><b>".$row["author"]."</b><br /><br />".prettyforumdate($row["postdate"])."</td><td style=\"background-color:#eeeeee; vertical-align:top;\">".nl2br(smilies($row["content"]))."</td></tr>\n"; $count = 1; } } $page .= "</table></td></tr></table><br />"; $page .= "<table width=\"100%\"><tr><td><b>Reply To This Thread:</b><br /><form action=\"forum.php?do=reply\" method=\"post\"><input type=\"hidden\" name=\"parent\" value=\"$id\" /><input type=\"hidden\" name=\"title\" value=\"Re: ".$row2["title"]."\" /><textarea name=\"content\" rows=\"7\" cols=\"40\"></textarea><br /><input type=\"submit\" name=\"submit\" value=\"Submit\" /> <input type=\"reset\" name=\"reset\" value=\"Reset\" /></form></td></tr></table>"; display($page, "Forum"); }function reply() { global $userrow; extract($_POST); $query = doquery("INSERT INTO {{table}} SET id='',postdate=NOW(),newpostdate=NOW(),author='".$userrow["charname"]."',parent='$parent',replies='0',title='$title',content='$content'", "forum"); $query2 = doquery("UPDATE {{table}} SET newpostdate=NOW(),replies=replies+1 WHERE id='$parent' LIMIT 1", "forum"); header("Location: forum.php?do=thread:$parent:0"); die(); }function newthread() { global $userrow; if (isset($_POST["submit"])) { extract($_POST); $query = doquery("INSERT INTO {{table}} SET id='',postdate=NOW(),newpostdate=NOW(),author='".$userrow["charname"]."',parent='0',replies='0',title='$title',content='$content'", "forum"); header("Location: forum.php"); die(); } $page = "<table width=\"100%\"><tr><td><b>Make A New Post:</b><br /><br/ ><form action=\"forum.php?do=new\" method=\"post\">Title:<br /><input type=\"text\" name=\"title\" size=\"50\" maxlength=\"50\" /><br /><br />Message:<br /><textarea name=\"content\" rows=\"7\" cols=\"40\"></textarea><br /><br /><input type=\"submit\" name=\"submit\" value=\"Submit\" /> <input type=\"reset\" name=\"reset\" value=\"Reset\" /></form></td></tr></table>"; display($page, "Forum"); } [/code]I did that and I get this error Messege with my forums:[b]Fatal error: Call to undefined function: smilies() in /home/spyderw/public_html/mf/forum.php on line 61[/b]Confused, Please help me, I been trying all day. :-( Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65412 Share on other sites More sharing options...
wildteen88 Posted July 28, 2006 Share Posted July 28, 2006 The code should be this:[code=php:0]function smilies($forum) { // defines the emoticons $emoticonarray = array( ":)" => "smile.gif", ":King:" => "king.gif", ":*" => "kiss.gif" ":lol:" => "lol.gif", ":loser:" => "loser.gif", ":money:" => "moneybag.gif" ":muscle:" => "muscle.gif", ":no:" => "no.gif", ":nono:" => "nono.gif" ":offwall:" => "offwall.gif", ":ohboy:" => "ohboy.gif", ":pc:" => "pc.gif" ":please:" => "please.gif", ":rofl:" => "rofl.gif", ":roll:" => "rolleyes.gif" // generates the search and replace arrays foreach($emoticonarray as $emoticon => $img) { $search[] = $emoticon; $replace[] = "<img src="emoticons/" . $img . "" alt="" . $emoticon . "" />"; } // searches the text passed to the function $text = str_ireplace($search, $replace, $text); // return the value return $forum;}function showthread($id, $start) { $query = doquery("SELECT * FROM {{table}} WHERE id='$id' OR parent='$id' ORDER BY id LIMIT $start,100", "forum"); $query2 = doquery("SELECT title FROM {{table}} WHERE id='$id' LIMIT 1", "forum"); $row2 = mysql_fetch_array($query2); $page = "<table width=\"100%\"><tr><td style=\"padding:1px; background-color:black;\"><table width=\"100%\" style=\"margins:0px;\" cellspacing=\"1\" cellpadding=\"3\"><tr><td colspan=\"2\" style=\"background-color:#dddddd;\"><b><a href=\"forum.php\">Forum</a> :: ".$row2["title"]."</b></td></tr>\n"; $count = 1; while ($row = mysql_fetch_array($query)) { if ($count == 1) { $page .= "<tr><td width=\"25%\" style=\"background-color:#ffffff; vertical-align:top;\"><span class=\"small\"><b>".$row["author"]."</b><br /><br />".prettyforumdate($row["postdate"])."</td><td style=\"background-color:#ffffff; vertical-align:top;\">".nl2br(smilies($row["content"]))."</td></tr>\n"; $count = 2; } else { $page .= "<tr><td width=\"25%\" style=\"background-color:#eeeeee; vertical-align:top;\"><span class=\"small\"><b>".$row["author"]."</b><br /><br />".prettyforumdate($row["postdate"])."</td><td style=\"background-color:#eeeeee; vertical-align:top;\">".nl2br(smilies($row["content"]))."</td></tr>\n"; $count = 1; } } $page .= "</table></td></tr></table><br />"; $page .= "<table width=\"100%\"><tr><td><b>Reply To This Thread:</b><br /><form action=\"forum.php?do=reply\" method=\"post\"><input type=\"hidden\" name=\"parent\" value=\"$id\" /><input type=\"hidden\" name=\"title\" value=\"Re: ".$row2["title"]."\" /><textarea name=\"content\" rows=\"7\" cols=\"40\"></textarea><br /><input type=\"submit\" name=\"submit\" value=\"Submit\" /> <input type=\"reset\" name=\"reset\" value=\"Reset\" /></form></td></tr></table>"; display($page, "Forum"); }[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15900-how-do-you-add-smiles-to-your-forums/#findComment-65420 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.