almightyegg Posted October 20, 2006 Share Posted October 20, 2006 i have made my own message board, but i want to add smilies. just ones which when you put a colon and a bracket that it recognises it as an image....how would i do this??? Quote Link to comment https://forums.phpfreaks.com/topic/24558-smilies-in-php-message-board/ Share on other sites More sharing options...
wildteen88 Posted October 20, 2006 Share Posted October 20, 2006 Search google or whatever foir emoticon tutorial or search this forum. There has been posts like yours a few times.However [url=http://ryanslife.net/2006/07/12/php-simple-emoticon-support/]this tutorial[/url] should get you going. Quote Link to comment https://forums.phpfreaks.com/topic/24558-smilies-in-php-message-board/#findComment-112006 Share on other sites More sharing options...
almightyegg Posted October 21, 2006 Author Share Posted October 21, 2006 thanks ill take a look :) Quote Link to comment https://forums.phpfreaks.com/topic/24558-smilies-in-php-message-board/#findComment-112220 Share on other sites More sharing options...
almightyegg Posted October 21, 2006 Author Share Posted October 21, 2006 i get an error...but i dont understand :(Parse error: syntax error, unexpected '[', expecting ')' in /home/lordofth/public_html/forum/viewthread.php on line 78[code]<? function emoticon($r['post']) { // the line below this is line 78 $emoticonarray = array( ':)' => 'smile.gif', ':(' => 'sad.gif', ';)' => 'wink.gif', ':P' => 'tongue.gif' ); foreach($emoticonarray as $emoticon => $img) { $search[] = $emoticon; $replace[] = '<img src="/emoticons/' . $img . '" alt="' . $emoticon . '" />'; } $r['post'] = str_replace($search, $replace, $r['post']); return $r['post'];} echo stripslashes($r['username']); ?></td> <td style="width:80%;background-color:#101010;"> <? echo nl2br(stripslashes($r['post'])); ?></td> </tr></table>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24558-smilies-in-php-message-board/#findComment-112234 Share on other sites More sharing options...
wildteen88 Posted October 21, 2006 Share Posted October 21, 2006 Its actually to do with this:[code=php:0]function emoticon($r['post']) {[/code]You cannot use an array as parameter for tghe function, you can passa n array to the function when you call it. So remove the $r['post'] variable and replace it with $r_post or something similiar. Also make sure chnage any other instances of $r['post'] too in the emoticon function to $r_post too.Then when you call the emotion function you can use $r['post']:[code=php:0]// call the emoticon function$r['post'] = emoticon($r['post']);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24558-smilies-in-php-message-board/#findComment-112265 Share on other sites More sharing options...
almightyegg Posted October 22, 2006 Author Share Posted October 22, 2006 didn't really understand that :(could you rewrite this? then in future i will understand :)[code] function emoticon($r['post']) { // defines the emoticons $emoticonarray = array( ':)' => 'smile.gif', ':(' => 'sad.gif', ';)' => 'wink.gif', ':P' => 'tongue.gif', ':'(' => 'cry.gif' ); foreach($emoticonarray as $emoticon => $img) { $search[] = $emoticon; $replace[] = '<img src="images/emotions/' . $img . '" alt="' . $emoticon . '" />'; } $r['post'] = str_replace($search, $replace, $r['post']); return $r['post'];} echo stripslashes($r['username']); ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24558-smilies-in-php-message-board/#findComment-112744 Share on other sites More sharing options...
almightyegg Posted October 22, 2006 Author Share Posted October 22, 2006 anyone? if you don't want to rewrite then can you then explain in simple terms what wildteen88 said??? Quote Link to comment https://forums.phpfreaks.com/topic/24558-smilies-in-php-message-board/#findComment-112756 Share on other sites More sharing options...
almightyegg Posted October 22, 2006 Author Share Posted October 22, 2006 sorry to post again but nobody replied :( Quote Link to comment https://forums.phpfreaks.com/topic/24558-smilies-in-php-message-board/#findComment-112818 Share on other sites More sharing options...
wildteen88 Posted October 23, 2006 Share Posted October 23, 2006 You need to read up on creating your own functions if you are not understanding the code. Prehaps reading [url=http://dev.fyicenter.com/faq/php/php_function_definition.php]this[/url] may help yuou understand.if you follow what I said IN my previous post your function should work. However the following is what your code should be:[code]// we difine our function here// PHP will not run this function until we tell it to// $post is the paramter for the function.function emoticon($post){ // defines the emoticons $emoticonarray = array( ':)' => 'smile.gif', ':(' => 'sad.gif', ';)' => 'wink.gif', ':P' => 'tongue.gif', ':(' => 'cry.gif' ); foreach($emoticonarray as $emoticon => $img) { $search[] = $emoticon; $replace[] = '<img src="images/emotions/' . $img . '" alt="' . $emoticon . '" />'; } $post = str_replace($search, $replace, $post); return $post;}// We'll now tell PHP to run our emoticon function we defined above:// we'll pass $r['post'] as a paramter to the emoticon function.// The function will now converet any smilie symbols in to images$r['post'] = emoticon($r['post']);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24558-smilies-in-php-message-board/#findComment-113272 Share on other sites More sharing options...
HuggieBear Posted October 23, 2006 Share Posted October 23, 2006 This has been answered now in another post!The user obviously double posted, I didn't see this one :(RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/24558-smilies-in-php-message-board/#findComment-113275 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.