Jump to content

[SOLVED] PHP Stops Half Way Through


Etherwood

Recommended Posts

My php script is stopping half way through my script.

 

   // Validate Password
    if ($_POST['password'] != "") {
      $password = $_POST['password'];
    } else {
      $errors .= 'Please enter your a password.<br/>';
    }
echo 2;
   // Validate Name
    if ($_POST['name'] != "") {
      $name = filter_var($_POST['name'], FILTER_SANITIZE_STRING);
      if ($name == "") {
        $errors .= 'Please enter a valid name.<br/><br/>';
      }
    } else {
      $errors .= 'Please enter your a name.<br/>';
    }
echo 3;

 

I added echo tags to see where it stops. It echos 2 but not 3.

 

Any suggestions?

Link to comment
https://forums.phpfreaks.com/topic/181682-solved-php-stops-half-way-through/
Share on other sites

You are likely getting a fatal runtime error at the filter_var() instruction. Are you developing and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in you master php.ini so that php would display all the errors it detect? You would save a ton of time.

    // Validate Database
    if ($_POST['database'] != "") {
      $database = filter_var($_POST['database'], FILTER_SANITIZE_STRING);
      if ($database == "") {
        $errors .= 'Please enter a valid database name.<br/><br/>';
      }
    } else {
      $errors .= 'Please enter your a database name.<br/>';
    }
echo 1;
   // Validate Password
    if ($_POST['password'] != "") {
      $password = $_POST['password'];
    } else {
      $errors .= 'Please enter your a password.<br/>';
    }
echo 2;
   // Validate Name
    if ($_POST['name'] != "") {
      $name = filter_var($_POST['name'], FILTER_SANITIZE_STRING);
      if ($name == "") {
        $errors .= 'Please enter a valid name.<br/><br/>';
      }
    } else {
      $errors .= 'Please enter your a name.<br/>';
    }
echo 3;

 

With error reporting now set to on, it returns this:

 

Fatal error: Call to undefined function filter_var() in /var/www/html/manager/createdb.php on line 37

I've upgraded the centos repo to support a yum update. Ran the yum update to install 5.2.9, then enabled the error loggin again, restarted httpd. Loaded the same page, but this time its blank with no output at all.

 

Edit: PHP is working because I get output from phpinfo()

OK, Heres the latest...  I have removed both PHP and HTTPD, then reinstalled them.

It now loads my registration script but with a new error:

Notice: Undefined variable: errors in /var/www/html/manager/createdb.php on line 65

 

Line 65:

$errors .= "$email is <strong>NOT</strong> a valid email address.<br/><br/>";

 

Is 5.2 more strict than 5.1 or something?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.