Page 1 of 1

eregi_replace

Posted: Wed Jun 29, 2005 2:11 pm
by orchidpsycho
Hi I am fairly new to php but I know a few other languages from school.
I have been working on a guestbook for my website. All is going good but
I have come across 2 problems that I can't seem to fix. I have googled and
searched several tutorials. I am sure it is something small that I am
overlooking so I thought I would ask for help. I wrote some smiley code
and and swear word filter and when I use this code it works fine

Code: Select all

$oldemo = array(":-)", ":-(", ":-[", ":-]", ";-)", ":+(", "badword", "badword", "badword");
$newemo  = array("<img src=images/1.gif>", "<img src=images/2.gif>", 
"<img src=images/3.gif>","<img src=images/4.gif>", "<img src=images/5.gif>",
 "<img src=images/6.gif>","*&%@#$%","*&%@#$%","*&%@#$%");
$newtext = str_replace($oldemo, $newemo, $comment);
That would be o.k. but then I figured out that the str_replace function is
case sensative. So I tried to use the eregi_replace like this

Code: Select all

$oldemo = array(":-)", ":-(", ":-[", ":-]", ";-)", ":+(", "badword", "badword", "badword");
$newemo  = array("<img src=images/1.gif>", "<img src=images/2.gif>",
 "<img src=images/3.gif>","<img src=images/4.gif>", "<img src=images/5.gif>", 
"<img src=images/6.gif>","*&%@#$%","*&%@#$%","*&%@#$%");
$newtext = eregi_replace($oldemo, $newemo, $comment);
All the reading I have done says the eregi_replace can be used just like the
str_replace function?

The next problem I have is formatting a timestamp from the sql server. When
I have done this in other queries it works fine but this is the first query
where I am pulling data from multiple tables? Could that have something to do
with it? Here is the code I usually use

Code: Select all

DATE_FORMAT(gbook.date, '%a %b %d, %Y | %r' )
here is the query:

Code: Select all

SELECT gbook.id,gbook.name,gbook.email,gbook.location,gbook.homepage,
gbook.icq,gbook.aim,gbook.comment,gbook.gender,
DATE_FORMAT(gbook.date, '%a %b %d, %Y | %r' ),gbook.browser,gbook.os,styles.pagebackground,
styles.headerbackground,styles.tablebackground,styles.contentbackground,
styles.headertextcolor,styles.headertextsize,styles.timecolor,styles.nametextcolor,
styles.nametextsize, styles.infotextcolor, styles.infotextsize,styles.datetextcolor, 
styles.datetextsize, styles.commenttextcolor, styles.commenttextsize,styles.infobackground,
 styles.commentbackground,styles.timeborder,styles.contentborder,styles.bannerborder,
styles.linkcolors,styles.swear FROM gbook,styles
Any help would be greatly appreciated. Also you can view the guestbook I am working on at http://www.recoveryuniverse.com/guest