Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a site on shared hosting I'm moving to a Centos 5.8 VPS - the pages all load fine, which include a bunch of local php with various arrays, replaces and file reads, but the submit form php fails - i've included various echo's at different points and found that after the line

$txt = filter_var($txt,FILTER_SANITIZE_SPECIAL_CHARS);

no echo will display and script never reaches the end (a redirect) - resulting in a blank screen or a screen only displaying the echo's before that line

if I remove that line the script reaches the end, but doesn't write to the files it's supposed to. that code is just the basic:

//open the file and choose the mode

$fh = fopen("../file.txt", "a");

fwrite($fh, $data);



//close the file

fclose($fh);

What part of my setup could be different from the shared hosting setup that's causing this difference in behaviour? Am I missing a dependency or is something wrong with my config?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

It sounds like the PHP script is dying outright at that line; turning on error reporting while debugging will help with that (errors may already be in your Apache error.log). However, the most probable explanation is the filter_var function does not exist.

Two explanations come to mind:

  • Your PHP version is < 5.2.0; earlier versions of PHP do not have that function.
  • Your PHP was compiled without --enable-filter; check phpinfo() to see if filters are enabled for your PHP build.
share|improve this answer
1  
This answer is almost certainly correct. CentOS 5.x (and the upstream distribution, RHEL 5.x) have pegged their "php" package at 5.1.x. In order to gain access to a newer version, you'll need to either install the "php53" package family instead, install someone else's PHP distribution (like that of Remi, a PHP maintainer for Fedora), or custom-compile. –  Charles Apr 11 '12 at 6:39
    
Agreed. Remember when choosing from the above options, you should bear in mind the long-term maintenance of your PHP installation. yum update is a fairly easy maintenance task, while updating a custom compilation or even using an RPM you download manually is more onerous and therefore less likely to be done as often as you should. The CentOS/RHEL update model is you essentially want your package versions etched in stone, updated only for security reasons, never for shiny new features. Depending on which PHP distribution you use, you may find updates arrive far, far more frequently. –  Mike Apr 11 '12 at 6:45
    
-v number it is, I'll have to deal with the newer than recommended version of php, thanks guys! –  John Apr 11 '12 at 11:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.