desithugg Posted July 17, 2006 Share Posted July 17, 2006 umm im having trouble using str_replace i want to replace swear words on the $row['post'].I tried setting the row as a global vairable $post = $row['post'] but than it only filters the first post and the rest arent shown.Can someone help me with this.[code]<?php$link = mysql_connect('localhost', '1135394704283249', '0309192909121845');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,15"; $result = mysql_query($query) or die(mysql_error());while($row = mysql_fetch_array($result)){$count++;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] Quote Link to comment https://forums.phpfreaks.com/topic/14862-str_replace/ Share on other sites More sharing options...
wildteen88 Posted July 17, 2006 Share Posted July 17, 2006 Use an arrray:[code=php:0]$bad_words = array('shit', 'fuck', 'piss');$post = str_replace($bad_words, '', $post);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14862-str_replace/#findComment-59501 Share on other sites More sharing options...
desithugg Posted July 17, 2006 Author Share Posted July 17, 2006 [quote author=wildteen88 link=topic=100900.msg398772#msg398772 date=1153156796]Use an arrray:[code=php:0]$bad_words = array('shit', 'fuck', 'piss');$post = str_replace($bad_words, '', $post);[/code][/quote]i have tried that but when i try assinging$post to $row['$post'] it doesnt work and when it does work it only displayes 1 post i want it to do the samw with all of them Quote Link to comment https://forums.phpfreaks.com/topic/14862-str_replace/#findComment-59505 Share on other sites More sharing options...
wildteen88 Posted July 17, 2006 Share Posted July 17, 2006 Do you have the code within your while loop like so:[code=php:0]while($row = mysql_fetch_array($result)){ $count++; $bad_words = array('shit', 'fuck', 'piss'); $row['post'] = str_replace($bad_words, '', $row['post']); // rest of code here[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14862-str_replace/#findComment-59506 Share on other sites More sharing options...
desithugg Posted July 17, 2006 Author Share Posted July 17, 2006 it worked thanks alot Quote Link to comment https://forums.phpfreaks.com/topic/14862-str_replace/#findComment-59516 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.