What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » php smilie code check

Pages: (3): « First [ 1 ] 2 3 » Last »
php smilie code check
Author: Message:
stoshrocket
Senior Member
****

Avatar
formerly methos

Posts: 748
Reputation: 31
33 / Male / Flag
Joined: Aug 2005
O.P. php smilie code check
ok, im crap at php, but give me a chance, atleast ive tried ok, this code is meant to replace smilie symbols with the image of the smilie, but when uploaded the whole page just gives me
'Parse error: parse error, unexpected T_STRING in /home2/skarz/public_html/methos2/test/index.php on line 19'
the code is as follows, it is included in the <head> tag and it starts from line 17 where <?php is...
code:
<?php

$text = str_replace(":)", "<img alt="smiley" src='smilies/grin.gif' />",
    str_replace("0:)", "<img alt="smiley" src='smilies/angel.gif' />",
    str_replace(":D", "<img alt="smiley" src='smilies/biggrin.gif' />",
rest of smilie code here, it takes too much room

$text);
?>


anyone see whats causing the error? thanks

This post was edited on 12-24-2005 at 02:49 PM by stoshrocket.
formerly methos
12-24-2005 02:45 PM
Profile PM Web Find Quote Report
user27089
Disabled Account


Posts: 6321
Joined: Nov 2003
Status: Away
RE: php smilie code check
str_replace("0Smilie", "<img alt="smiley" src='smilies/angel.gif' />",

it might be the "0" before the smilie...
12-24-2005 02:46 PM
Profile PM Find Quote Report
stoshrocket
Senior Member
****

Avatar
formerly methos

Posts: 748
Reputation: 31
33 / Male / Flag
Joined: Aug 2005
O.P. RE: php smilie code check
quote:
Originally posted by traxor
str_replace("0Smilie", "<img alt="smiley" src='smilies/angel.gif' />",

it might be the "0" before the smilie...

nope, thats just the actual symbol that would trigger it to replace it with angel.gif, wouldnt it, hang on, ill bold the line its saying i have an error on...
formerly methos
12-24-2005 02:47 PM
Profile PM Web Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: php smilie code check
cause you are using "" to enclose the strings and because you put "smiley" between them too it's not enclosed. I recommend using ' to enclose strings so you can use the " for html enclosing.

code:
$text = str_replace(':)', '<img alt="smiley" src="smilies/grin.gif" />',


This post was edited on 12-24-2005 at 03:02 PM by Ezra.
[Image: 1-0.png]
             
12-24-2005 02:55 PM
Profile PM Web Find Quote Report
Stigmata
Veteran Member
*****



Posts: 3520
Reputation: 45
20 / Other / Flag
Joined: Jul 2003
RE: php smilie code check
code:
$text = preg_replace("(a)", "<img alt='smiley' src='smilies/angel.gif' />", $text)


That will work perfectly.

This post was edited on 12-24-2005 at 03:16 PM by Stigmata.
12-24-2005 03:13 PM
Profile PM Web Find Quote Report
Plik
Veteran Member
*****

Avatar

Posts: 1489
Reputation: 46
34 / Male / –
Joined: Jun 2004
RE: php smilie code check
* Plik pukes
i suggest you read up on the basic php syntax because what your trying to do is horibly wrong, but to get you started this should* work
code:

<?php

$smiley_list = array(":)", "0:)", ":D", the rest of the smilies);
$replacement_list = array('<img alt="smiley" src="smilies/grin.gif" />', '<img alt="smiley" src="smilies/angel.gif" />', '<img alt="smiley" src="smilies/biggrin.gif" />', The rest of the replacements here, using this format: '<img alt="alttext" src="location' />");

$text = str_replace($smiley_list, $replacement_list, $text);
?>

If you are unsure about a function always refer to http://php.net
str_replace

also stiggys way works for each one :P

*i havnt tested it :P
12-24-2005 03:15 PM
Profile PM Find Quote Report
absorbation
Elite Member
*****

Avatar

Posts: 3636
Reputation: 81
– / Male / Flag
Joined: Feb 2005
RE: php smilie code check
quote:
Originally posted by Methos2
it is included in the <head> tag

it should not matter, you can place the php anywhere it will excute in the same way, you only really want php in a disired place where you want to php to display content using print or echo :P (just an heads up php is not like javascript for stuff like this ;) )
12-24-2005 03:47 PM
Profile PM Find Quote Report
stoshrocket
Senior Member
****

Avatar
formerly methos

Posts: 748
Reputation: 31
33 / Male / Flag
Joined: Aug 2005
O.P. RE: php smilie code check
quote:
Originally posted by Madman
* Madman pukes

i suggest you read up on the basic php syntax because what your trying to do is horibly wrong, but to get you started this should* work
code:

<?php

$smiley_list = array(":)", "0:)", ":D", the rest of the smilies);
$replacement_list = array('<img alt="smiley" src="smilies/grin.gif" />', '<img alt="smiley" src="smilies/angel.gif" />', '<img alt="smiley" src="smilies/biggrin.gif" />', The rest of the replacements here, using this format: '<img alt="alttext" src="location' />");

$text = str_replace($smiley_list, $replacement_list, $text);
?>

If you are unsure about a function always refer to http://php.net
str_replace

also stiggys way works for each one :P

*i havnt tested it :P

ok, thats stopped the errors running up although, am i missing something, its still showing up as :o when i type it, oh noes!
formerly methos
12-24-2005 03:49 PM
Profile PM Web Find Quote Report
Veggie
Full Member
***

Avatar

Posts: 415
Reputation: 21
37 / Male / Flag
Joined: Sep 2004
RE: php smilie code check
is the text you type in the $text variable?
12-24-2005 04:33 PM
Profile E-Mail PM Web Find Quote Report
stoshrocket
Senior Member
****

Avatar
formerly methos

Posts: 748
Reputation: 31
33 / Male / Flag
Joined: Aug 2005
O.P. RE: php smilie code check
quote:
Originally posted by Veggie
is the text you type in the $text variable?

:S explain please :$

This post was edited on 12-24-2005 at 04:36 PM by stoshrocket.
formerly methos
12-24-2005 04:36 PM
Profile PM Web Find Quote Report
Pages: (3): « First [ 1 ] 2 3 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On