Jump to content

Archived

This topic is now archived and is closed to further replies.

desithugg

str_replace

Recommended Posts

umm having trouble again with str_replace
[code]
The arrays
<?php
   $filter=array(
   
   
    ':)' => "<img src='images/smile.gif'>",
    ':(' => "<img src='images/sad.gif'>",
    ':tounge:' => "<img src='images/tongue.gif'>",
    ':wink:' => "<img src='images/wink.gif'>",
    ';smirk' => "<img src='images/smirk.gif'>",
    ':blush:' =>"<img src='images/blush.gif'>",
    ':angry' =>"<img src='images/angry.gif'>",
    ':o'=>     "<img src='images/shocked.gif'>",
    ':shocked'=>     "<img src='images/shocked.gif' />",
    ':ninja'=>"<img src='images/ninja.gif' />",
    ':cool'=>"<img src='images/cool.gif' />",
    '(!)'=>"<img src='images/exclamation.gif' />",
    '(?)'=>"<img src='images/question.gif' />",
    '(heart)'=>"<img src='images/heart.gif' />",
    ':{blink}'=>"<img src='images/winking.gif'>",
    '{clover}'=>"<img src='images/clover.gif'>",
    ':[glasses]'=>"<img src='images/glasses.gif'>",
    ':[barf]'=>"<img src='images/barf.gif'>",
    ':[reallymad]'=>"<img src='images/mad.gif'>",
'gay'=>"g*y",
'ass'=>"a*s",
    'fuck'=>"fu*k",
    'Fuck'=>"fu*ck",
'bitch'=>"bi**ch",
    'nigger'=>"nig*er",
'dick'=>"di*k",
    'paki'=>"pa*i"
    );
?>
and the query
<?php
$link = mysql_connect('localhost', '$user', '$pass');
if (!$link) {
   die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('tpf');
if (!$db_selected) {
   die('Could not select database: ' . mysql_error());
}
$query = "SELECT author,post,id FROM post where thread_id = '$thread_id' ORDER BY id ASC limit $start,10";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)) { $count++; str_replace(array_keys($filter), array_values($filter), $row['post']);
echo "<tr><td width='20%' class='nav2' height='130'><a href='http://tpfrpg.byethost32.com/members/index.php?action=view&user1=". $row['author'] ."' class='links'>". $row['author'] ."</a><br><img src='http://tpfrpg.byethost32.com/members/sprite.php?user=". $row['author'] ."'><br><a href='javascript:void(0)' onClick=expandcontent('roster$count')>Roster</a><div id='roster$count' class='switchcontent'><img src='http://tpfrpg.byethost32.com/members/roster.php?user=". $row['author'] ."&slot=1'><img src='http://tpfrpg.byethost32.com/members/roster.php?user=". $row['author'] ."&slot=3'><img src='http://tpfrpg.byethost32.com/members/roster.php?user=". $row['author'] ."&slot=4'><br><img src='http://tpfrpg.byethost32.com/members/roster.php?user=". $row['author'] ."&slot=4'><img src='http://tpfrpg.byethost32.com/members/roster.php?user=". $row['author'] ."&slot=5'><img src='http://tpfrpg.byethost32.com/members/roster.php?user=". $row['author'] ."&slot=6'></div><br><img src='/members/strip.php?user=". $row['author'] ."'></td><td width='60%' class='nav2'>". $row['post'] ."</td><td width='20%' class='nav2'><a href='index.php?action=editpost&post_id=". $row['id'] ."'><img src='http://i63.photobucket.com/albums/h159/saad430/edit.gif' border='0'></a><br><img src='http://i63.photobucket.com/albums/h159/saad430/quote.gif' border='0'><br><a href='index.php?action=deletepost&post_id=". $row['id'] ."'><img src='http://i63.photobucket.com/albums/h159/saad430/delete.gif' border='0'></a><br><img src='http://i63.photobucket.com/albums/h159/saad430/report.gif' border='0'></a></td>";
}
?>
[/code]

i cant see any problem with it

Share this post


Link to post
Share on other sites
it's probably because you're not actually assigning the str_replace() to anything.  it doesn't edit the input string itself, it returns the new string.  try:

[code]$row['post'] = str_replace(stuff);[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.