sawade Posted September 28, 2009 Share Posted September 28, 2009 Hello all. Well I am stumped. Profoundly stumped. I took a current php script I wrote previously and revamped it. Using a few new functions that hadn't been used in the first script. I can view my first script fine on the internet, however when I try to debug/test this new scipt my server gives me a 500 error. I have checked my php.ini and there is nothing in it that I can see that should be causing a conflict. So... I am asking for help. Below is the new code... <?php ini_set("display_errors", "1"); error_reporting(E_ALL); //error_reporting(E_ALL ^ E_NOTICE); session_start(); setlocale(LC_ALL, ''); ?> HTML head tag... etc... if (isset($_POST['submit'])) { $error = '';//initialize $error to blank ... lists additional variables Here is an example of the strings I added... if (empty($first_name) && empty($last_name)) { // IF first and last are empty - REQUIRED FIELD $error .= 'Please input your FIRST NAME and LAST NAME.<br />'; $output_form = true; } if (empty($first_name)) { // IF first only is empty - REQUIRED FIELD $error .= 'Please input your FIRST NAME.<br />'; $output_form = true; } else { if (!empty($first_name) && strlen($first_name) < 2 || strlen($first_name) > 30) { // IF first is not empty and is not between 2 and 30 characters $error .= 'FIRST NAME must be between 2 and 30 characters.<br />'; $output_form = true; } } else { if (!empty($first_name) && !ctype_alpha($first_name)) { // IF first is not empty and contains illegal characters $error .= 'FIRST NAME contains illegal characters.<br />'; $output_form = true; } } etc... several hundred lines of code in between... } else { $output_form = true; } if ($error=='') { //IF NO errors process form ...email address validator ...captcah validator ... if all clear runs the email script ...echo confirmation } else{ echo '<p class="error">'$error'</p>';// List errors } } else { // Email not valid $error .= 'Please input a VALID EMAIL ADDRESS.<br />'; $output_form = true; } } else { // CAPTCHA not valid $error .= 'Please enter the VERIFICATION PASS-PHRASE exactly as shown.<br />'; $output_form = true; } } if ($output_form == true) { ?> <div id="form"> <form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>"> <p id="required">*Indicates a required field</p> Additional HTML code for form. Quote Link to comment https://forums.phpfreaks.com/topic/175843-solved-stumped-500-error/ Share on other sites More sharing options...
play_ Posted September 28, 2009 Share Posted September 28, 2009 Whenever i get those, it's a problem with the server configuration. best bet is to comment out blocks of code until it works and you know what's causing the problem Quote Link to comment https://forums.phpfreaks.com/topic/175843-solved-stumped-500-error/#findComment-926589 Share on other sites More sharing options...
sawade Posted October 1, 2009 Author Share Posted October 1, 2009 Whenever i get those, it's a problem with the server configuration. best bet is to comment out blocks of code until it works and you know what's causing the problem I am doing just that. I get the error as soon as the code for the ctype_*() functions are input. My server is running the most up-to-date php version... why could this be happening?? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/175843-solved-stumped-500-error/#findComment-928533 Share on other sites More sharing options...
PFMaBiSmAd Posted October 1, 2009 Share Posted October 1, 2009 You are likely getting a fatal parse error. Putting the two lines - ini_set("display_errors", "1");/ error_reporting(E_ALL); in your script won't help display fatal parse errors. Those lines are only used/suggested for in a script file when it appears that the code is actually being executed (parse errors prevent the code from even being executed.) Set the display_errors/error_reporting settings in your php.ini in order to see all the php detected errors. Stop and start your web server to get any change made to php.ini to take effect. Quote Link to comment https://forums.phpfreaks.com/topic/175843-solved-stumped-500-error/#findComment-928536 Share on other sites More sharing options...
sawade Posted October 1, 2009 Author Share Posted October 1, 2009 You are likely getting a fatal parse error. Putting the two lines - ini_set("display_errors", "1");/ error_reporting(E_ALL); in your script won't help display fatal parse errors. Those lines are only used/suggested for in a script file when it appears that the code is actually being executed (parse errors prevent the code from even being executed.) Set the display_errors/error_reporting settings in your php.ini in order to see all the php detected errors. Stop and start your web server to get any change made to php.ini to take effect. Those lines are only in the file during testing, then are removed. I have my php.ini file set up for logging errors not showing them. And my error logs are completely empty. Nothing is being passed into them. Quote Link to comment https://forums.phpfreaks.com/topic/175843-solved-stumped-500-error/#findComment-928539 Share on other sites More sharing options...
PFMaBiSmAd Posted October 1, 2009 Share Posted October 1, 2009 And you have confirmed the actual runtime values of the error_reporting and log_errors settings using a phpinfo() statement? Beyond that, you would need to post actual code that produces the symptom. Quote Link to comment https://forums.phpfreaks.com/topic/175843-solved-stumped-500-error/#findComment-928544 Share on other sites More sharing options...
sawade Posted October 1, 2009 Author Share Posted October 1, 2009 And you have confirmed the actual runtime values of the error_reporting and log_errors settings using a phpinfo() statement? Beyond that, you would need to post actual code that produces the symptom. Yes. if (!empty($first_name) && !ctype_alpha($first_name)) { Any use of the ctype_*() function creates the 500 error. But does not send an error to the php log or any of my other error logs. All I get is the internal server error. If I remove the ctype the script runs like clockwork. I have sent an email to my host server, thinking maybe with their master config. they do not allow this function. Should this prove to be true... anything ideas of an alternate function to use? Quote Link to comment https://forums.phpfreaks.com/topic/175843-solved-stumped-500-error/#findComment-928545 Share on other sites More sharing options...
cags Posted October 1, 2009 Share Posted October 1, 2009 How about? <?php if(preg_match("/^[a-z]*$/i", $first_name)) { //all alphabetic chars } ?> Quote Link to comment https://forums.phpfreaks.com/topic/175843-solved-stumped-500-error/#findComment-928554 Share on other sites More sharing options...
jon23d Posted October 1, 2009 Share Posted October 1, 2009 What does your apache error log say? Quote Link to comment https://forums.phpfreaks.com/topic/175843-solved-stumped-500-error/#findComment-928605 Share on other sites More sharing options...
sawade Posted October 2, 2009 Author Share Posted October 2, 2009 LOL You know. It never ceases to amaze me how something so small can totally mess up the whole thing. Chalk it up as a Homer Simpson... D'ohhh!!! After hours of brooding... here was issue... if (empty($first_name) && empty($last_name)) { // IF first and last are empty - REQUIRED FIELD $error .= 'Please input your FIRST NAME and LAST NAME.<br />'; $output_form = true; } if (empty($first_name)) { // IF first only is empty - REQUIRED FIELD $error .= 'Please input your FIRST NAME.<br />'; $output_form = true; } else { if (!empty($first_name) && strlen($first_name) < 2 || strlen($first_name) > 30) { // IF first is not empty and is not between 2 and 30 characters $error .= 'FIRST NAME must be between 2 and 30 characters.<br />'; $output_form = true; } } else { if (!empty($first_name) && !ctype_alpha($first_name)) { // IF first is not empty and contains illegal characters $error .= 'FIRST NAME contains illegal characters.<br />'; $output_form = true; } } I was thinking it was the ctype, but really it's the if else statements. They should be as follows... if (empty($first_name) && empty($last_name)) { // IF first and last are empty - REQUIRED FIELD $error .= 'Please input your FIRST NAME and LAST NAME.<br />'; $output_form = true; } if (empty($first_name)) { // IF first only is empty - REQUIRED FIELD $error .= 'Please input your FIRST NAME.<br />'; $output_form = true; } if (!empty($first_name) && strlen($first_name) < 2 || strlen($first_name) > 30) { // IF first is not empty and is not between 2 and 30 characters $error .= 'FIRST NAME must be between 2 and 30 characters.<br />'; $output_form = true; } if (!empty($first_name) && !ctype_alpha($first_name)) { // IF first is not empty and contains illegal characters $error .= 'FIRST NAME contains illegal characters.<br />'; $output_form = true; } Well that's what I get for trying to get it scripted out too quickly. Better to take your time and do it right the first time. LOL Thanks all for the assistance. Quote Link to comment https://forums.phpfreaks.com/topic/175843-solved-stumped-500-error/#findComment-928798 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.