1

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?

1 Answer 1

3

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.
3
  • 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. Commented Apr 11, 2012 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. Commented Apr 11, 2012 at 6:45
  • -v number it is, I'll have to deal with the newer than recommended version of php, thanks guys! Commented Apr 11, 2012 at 11:21

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.