Strip words from form PHP
Posted: Tue Nov 30, 2010 8:25 pm
Hi Guys
Just wondering if anyone here can help me out
I basically have a script that lets users post comments but I have it setup so that at the begin of every comment the user put in the script puts in hate automactically which is how I want it to work, but sometimes the user put in hating themselves and it comes out with hating hating and then users comment. Anyone have any ideas on how I can get it to strip out hating or hates if it is the first word in the sentence inputted by the user? At the moment I have it set to remove hating but it removes it where ever it is used in the sentence which is not good at the moment. Here is some of the code that is being used.
SET story='hating " is where I have set it to put in the word hating and include it in the database when submitted.
Thanks in advance an help is welcomed.
Mat
Just wondering if anyone here can help me out
I basically have a script that lets users post comments but I have it setup so that at the begin of every comment the user put in the script puts in hate automactically which is how I want it to work, but sometimes the user put in hating themselves and it comes out with hating hating and then users comment. Anyone have any ideas on how I can get it to strip out hating or hates if it is the first word in the sentence inputted by the user? At the moment I have it set to remove hating but it removes it where ever it is used in the sentence which is not good at the moment. Here is some of the code that is being used.
Code: Select all
if (strpos($content, 'hating') !== false) {
$content = str_replace("hating", "", $content);
}
$query="INSERT INTO posts SET story='hating ".mysql_real_escape_string($content)."', time_added='".time()."', date_added='".date("Y-m-d")."', active='$active', pip='".$_SERVER['REMOTE_ADDR']."'";
$result=$conn->execute($query);
$pid = mysql_insert_id();
Thanks in advance an help is welcomed.
Mat