Articles in the PHP Category
Posted: Mar 01 | Filed under: PHP
If you find this in your apache error.log: Premature end of script headers in index.php and get a 500 error on your wordpress blog, then you should check your suexec log. When it reaches 2GB you will receive a 500 error and the message: Premature end of script headers
You can find the log here: /var/log/apache/suexec.log or simply enter locate suexec.log
Also check your /var/log/suphp.log … if it is over 2GB large you will receive the 500 error!
Posted: Oct 17 | Filed under: Code Snippets, PHP
Let’s say you got a form and you don’t want to allow that people submit certain words. How would you do that? Right you will have to use the PHP function strpos. Unfortunately you can’t feed strpos with arrays (a list of needles)!
Here is a very simple solution that you can use to to check multiple needles and their occurence in a specific string.
$haystack = $myhaystack; $needle = array('badword','badword','badword','badword'); foreach($needle as $value){ $pos = strpos($haystack, $value); if ($pos !== false){ /* If we find one of those bad words do the following */ header("Location: http://mysite.com?error=badcontent"); exit; } }
I used the “header” command to redirect people to a specific site if they enter those bad words. You can output a customized error message by adding a variable at the end of the URL e.g. the variable “error”. Simply retrieve the variable via GET and then echo an appropriate message.
If you have any question feel free to ask!
Enjoy


