Etherwood Posted November 16, 2009 Share Posted November 16, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/181682-solved-php-stops-half-way-through/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 16, 2009 Share Posted November 16, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/181682-solved-php-stops-half-way-through/#findComment-958234 Share on other sites More sharing options...
Etherwood Posted November 16, 2009 Author Share Posted November 16, 2009 I know you can't see this but var_filter is used somewhere in the script before it gets to echo 2, so wouldn't it have stopped up there somewhere? Quote Link to comment https://forums.phpfreaks.com/topic/181682-solved-php-stops-half-way-through/#findComment-958235 Share on other sites More sharing options...
Etherwood Posted November 16, 2009 Author Share Posted November 16, 2009 // 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 Quote Link to comment https://forums.phpfreaks.com/topic/181682-solved-php-stops-half-way-through/#findComment-958238 Share on other sites More sharing options...
mikesta707 Posted November 16, 2009 Share Posted November 16, 2009 what version of PHP do you have? do you have the filter extension installed on your server Quote Link to comment https://forums.phpfreaks.com/topic/181682-solved-php-stops-half-way-through/#findComment-958239 Share on other sites More sharing options...
Etherwood Posted November 16, 2009 Author Share Posted November 16, 2009 I'm on the centos default build of 5.1.6, so I assume its not installed with this build? Quote Link to comment https://forums.phpfreaks.com/topic/181682-solved-php-stops-half-way-through/#findComment-958241 Share on other sites More sharing options...
mikesta707 Posted November 16, 2009 Share Posted November 16, 2009 nope, it was installed by default with versions after 5.2. clicky Quote Link to comment https://forums.phpfreaks.com/topic/181682-solved-php-stops-half-way-through/#findComment-958245 Share on other sites More sharing options...
Etherwood Posted November 16, 2009 Author Share Posted November 16, 2009 Balls Quote Link to comment https://forums.phpfreaks.com/topic/181682-solved-php-stops-half-way-through/#findComment-958248 Share on other sites More sharing options...
Etherwood Posted November 16, 2009 Author Share Posted November 16, 2009 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() Quote Link to comment https://forums.phpfreaks.com/topic/181682-solved-php-stops-half-way-through/#findComment-958255 Share on other sites More sharing options...
mikesta707 Posted November 16, 2009 Share Posted November 16, 2009 do you still have error reporting set to all? Quote Link to comment https://forums.phpfreaks.com/topic/181682-solved-php-stops-half-way-through/#findComment-958258 Share on other sites More sharing options...
Etherwood Posted November 16, 2009 Author Share Posted November 16, 2009 error_reporting = E_ALL display_errors = On Quote Link to comment https://forums.phpfreaks.com/topic/181682-solved-php-stops-half-way-through/#findComment-958262 Share on other sites More sharing options...
Etherwood Posted November 16, 2009 Author Share Posted November 16, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/181682-solved-php-stops-half-way-through/#findComment-958268 Share on other sites More sharing options...
mikesta707 Posted November 16, 2009 Share Posted November 16, 2009 you have to define the variable before you use the concatenation and assignment combo operator. something like $errors = ""; should fix the problem if you add that before your code Quote Link to comment https://forums.phpfreaks.com/topic/181682-solved-php-stops-half-way-through/#findComment-958272 Share on other sites More sharing options...
Etherwood Posted November 16, 2009 Author Share Posted November 16, 2009 Excellent stuff Cheers Quote Link to comment https://forums.phpfreaks.com/topic/181682-solved-php-stops-half-way-through/#findComment-958276 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.