Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi can anybody assist with this syntax error please. I'm trying to replace bad words with ":-x" when it is being retrieved from the database...

PHP
$bwords = aray("admin", "mod");
$pmsg = if($list['StringyChat_message'] = $bwords) {echo ":-x";} else { echo "$list['StringyChat_message']";}
Posted

1 solution

Try changing the line from
PHP
$pmsg = if($list['StringyChat_message'] = $bwords) {echo ":-x";} else { echo "$list['StringyChat_message']";}


To
PHP
$pmsg = ($list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message'];
 
Share this answer
 
Comments
cobusbo 29-Aug-14 5:54am    
Ok I changed it to $bwords = aray('ass', 'elo' );
$pmsg = ($list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message'];
// while there are rows to be fetched...
while ($list = mysql_fetch_assoc($result)) {
// echo data
echo '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] ) . ') ' . '</span>' . '' . $list['StringyChat_name'] . '' . ' : ' . $pmsg . '<br />';
} // end while
but now I get error Fatal error: Call to undefined function aray() in /home/u506124311/public_html/ag/page.php on line 44
ChauhanAjay 29-Aug-14 6:40am    
$bwords = aray("admin", "mod");
To
$bwords = array("admin", "mod");

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900