HartleySan Posted February 23, 2012 Share Posted February 23, 2012 For the spam scrubber function, I noticed that when I sticky the posted value from the comments text area back into the comments text area, all the newlines are removed. I tried using the nl2br and str_replace functions to change the newlines to <br> elements, but to no avail. Has anyone else encountered this issue and have a workable solution? Thank you. (By the way, I'm running PHP 5.2.x and MySQL on an Apache server.) Link to comment Share on other sites More sharing options...
HartleySan Posted February 24, 2012 Author Share Posted February 24, 2012 All right, I pulled a total newb move there. I totally missed something obvious. When I wrote the spam scrubber function last night, I wasn't thinking about what I was writing, and sure enough (as Larry explicitly says in the book), using the str_replace function to scrub your emails will mess up the formatting. Duh! Well, at least I solved it; just took out the str_replace function call at the end of the spam scrubber function. Thanks. Link to comment Share on other sites More sharing options...
Larry Posted February 25, 2012 Share Posted February 25, 2012 Or you could just display the original, non-scrubbed values in the form. Link to comment Share on other sites More sharing options...
HartleySan Posted February 25, 2012 Author Share Posted February 25, 2012 That too! I should learn to think more. Thanks. Link to comment Share on other sites More sharing options...
lutinFou Posted March 7, 2012 Share Posted March 7, 2012 Hi, i have used the spam_scrubber function on a form in which I have included a drop down list and radio buttons. When I use the spam_scrubber function to validate the other text areas, that it works fine, however once I select something I get a the following warnning message: Warning: stripos() expects parameter 1 to be string, array given in file name on line 18. line 18 is : f(stripos($value, $v)!==false) ) However I think the error is generated from the line $scrubbed=array_map('spam_scrubber', $_POST); i.e. the $value has to be a string for the function to work and since my select box returns an array, there is a problem, hence the error message. Is there a way around this,other than using a @ in front of the line above? Thanks, LF Link to comment Share on other sites More sharing options...
Larry Posted March 7, 2012 Share Posted March 7, 2012 You could have it only scrub the value if it's a string. Link to comment Share on other sites More sharing options...
Recommended Posts