more PHP help
more PHP help
http://bb.cinemasiafreaks.com/view/?tid=15#97
I have a part in the admin panel where I can set UBB tags if you will for smilies.
I simply comma seperate the different tags and put the smilie name and the tags as one long string into the DB, which takes one row as you might expect
in my forums etc the string needs to be exploded to determine the possible pseudonyms/ tags for a smilie in the DB (line 6+7)
for those images I have to create replacements to run through preg_replace(), which works fine (line 20)
however, the patterns also need to be dynamically generated, which is what kind of fails.
I need to escape certain characters in the pseudonyms, which I where I fail
basically it fails on smilies like: : ) and ; ) because of the ')', which needs to be escaped like '/:\)/'
this should happen on line 15
can someone tell me how I can insert a '\' before a ')' ????
should I just explode it, insert it and the put it back together?
I have a part in the admin panel where I can set UBB tags if you will for smilies.
I simply comma seperate the different tags and put the smilie name and the tags as one long string into the DB, which takes one row as you might expect
in my forums etc the string needs to be exploded to determine the possible pseudonyms/ tags for a smilie in the DB (line 6+7)
for those images I have to create replacements to run through preg_replace(), which works fine (line 20)
however, the patterns also need to be dynamically generated, which is what kind of fails.
I need to escape certain characters in the pseudonyms, which I where I fail
basically it fails on smilies like: : ) and ; ) because of the ')', which needs to be escaped like '/:\)/'
this should happen on line 15
can someone tell me how I can insert a '\' before a ')' ????
should I just explode it, insert it and the put it back together?
[i]And shepherds we shall be, for thee my Lord for thee, Power hath descended forth from thy hand, that our feet may swiftly carry out thy command, we shall flow a river forth to thee, and teeming with souls shall it ever be. In nomine patris, et fili, et spiritus sancti.[/i]
you didnt read properly4days wrote:give each smiley its own row in a table, or parse your smilies from a hard-coded array.
[i]And shepherds we shall be, for thee my Lord for thee, Power hath descended forth from thy hand, that our feet may swiftly carry out thy command, we shall flow a river forth to thee, and teeming with souls shall it ever be. In nomine patris, et fili, et spiritus sancti.[/i]
mmm, feared I had to resort to reg_exp, which is my worst nightmareglossy wrote:you mean:
$smilies = str_replace(")","\\)",$smilies); ??
[i]And shepherds we shall be, for thee my Lord for thee, Power hath descended forth from thy hand, that our feet may swiftly carry out thy command, we shall flow a river forth to thee, and teeming with souls shall it ever be. In nomine patris, et fili, et spiritus sancti.[/i]
glossy? http://bb.cinemasiafreaks.com/view/?tid=15#93
Warning: preg_replace(): No ending delimiter '/' found in preg_replace_smilies.php on line 33
Warning: preg_replace(): Compilation failed: missing terminating ] for character class at offset 3 in preg_replace_smilies.php on line 33
Warning: preg_replace(): No ending delimiter '/' found in preg_replace_smilies.php on line 33
Warning: preg_replace(): Compilation failed: missing terminating ] for character class at offset 3 in preg_replace_smilies.php on line 33
[i]And shepherds we shall be, for thee my Lord for thee, Power hath descended forth from thy hand, that our feet may swiftly carry out thy command, we shall flow a river forth to thee, and teeming with souls shall it ever be. In nomine patris, et fili, et spiritus sancti.[/i]
-
^misantropia^
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
thx, now I still have one error:
Warning: preg_replace(): No ending delimiter '/' found in preg_replace_smilies.php on line 34
Warning: preg_replace(): No ending delimiter '/' found in preg_replace_smilies.php on line 34
[i]And shepherds we shall be, for thee my Lord for thee, Power hath descended forth from thy hand, that our feet may swiftly carry out thy command, we shall flow a river forth to thee, and teeming with souls shall it ever be. In nomine patris, et fili, et spiritus sancti.[/i]
btw, it is stripping out slashes where it shouldnt
$this_pseudo = str_replace('[',"\\[",$this_pseudo);
$this_pseudo = str_replace(')',"\\)",$this_pseudo);
$this_pseudo = str_replace('\'',"\\'",$this_pseudo);
$this_pseudo = str_replace('/',"\\/",$this_pseudo);
$this_pseudo = str_replace('(',"\\(",$this_pseudo);
thats how it actually is listed :S
$this_pseudo = str_replace('[',"\\[",$this_pseudo);
$this_pseudo = str_replace(')',"\\)",$this_pseudo);
$this_pseudo = str_replace('\'',"\\'",$this_pseudo);
$this_pseudo = str_replace('/',"\\/",$this_pseudo);
$this_pseudo = str_replace('(',"\\(",$this_pseudo);
thats how it actually is listed :S
[i]And shepherds we shall be, for thee my Lord for thee, Power hath descended forth from thy hand, that our feet may swiftly carry out thy command, we shall flow a river forth to thee, and teeming with souls shall it ever be. In nomine patris, et fili, et spiritus sancti.[/i]
-
^misantropia^
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
Code: Select all
$this_pseudo = str_replace('\', '\\', $this_pseudo);
$this_pseudo = str_replace('[', '\[', $this_pseudo);
$this_pseudo = str_replace(')', '\)', $this_pseudo);
$this_pseudo = str_replace('/', '\/', $this_pseudo);
$this_pseudo = str_replace('(', '\(', $this_pseudo);the string replacements are fine, but there is another error now it fails on
[i]And shepherds we shall be, for thee my Lord for thee, Power hath descended forth from thy hand, that our feet may swiftly carry out thy command, we shall flow a river forth to thee, and teeming with souls shall it ever be. In nomine patris, et fili, et spiritus sancti.[/i]