Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.