soycharliente Posted December 8, 2008 Share Posted December 8, 2008 What are some possible causes for a PHP page to simply come up as a blank white page? It was working fine, I edited some code, and now it just comes up blank. No errors or partial source or anything. The file is long so I didn't want to post it. Just looking for some possible hints that I could check out myself before asking someone to look at it as a last resort. Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/ Share on other sites More sharing options...
premiso Posted December 8, 2008 Share Posted December 8, 2008 Error of some type and errors turned off. Try adding this to the top of the code: <?php error_reporting(E_ALL); ini_set('display_errors', 1); If it was a loop you added, make sure it is not doing an infinite loop. Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709728 Share on other sites More sharing options...
rhodesa Posted December 8, 2008 Share Posted December 8, 2008 Error of some type and errors turned off. Try adding this to the top of the code: <?php error_reporting(E_ALL); ini_set('display_errors', 1); If it was a loop you added, make sure it is not doing an infinite loop. if it's a syntax error, that won't show it though. so if the above doesn't work, try adding an .htaccess file in the directory with the following: php_value display_errors 1 Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709737 Share on other sites More sharing options...
soycharliente Posted December 8, 2008 Author Share Posted December 8, 2008 Still a blank page. None of that did anything. Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709750 Share on other sites More sharing options...
rhodesa Posted December 8, 2008 Share Posted December 8, 2008 Still a blank page. None of that did anything. well...looks like you'll have to post some code then. just make sure you use [ code ][/ code ] tags (without the spaces) Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709767 Share on other sites More sharing options...
premiso Posted December 8, 2008 Share Posted December 8, 2008 How about post some code? It is hard to diagnose without it. Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709775 Share on other sites More sharing options...
soycharliente Posted December 8, 2008 Author Share Posted December 8, 2008 I think I narrowed it down to a small section. When I take this out, the page loads fine. <?php if (isset($_POST['Submit']) && $_POST['Submit'] == "Submit") { foreach ($_POST as $key => $val) { $_POST[$key] = trim(stripslashes($val)); } $to = "xxx.xxx@xxx.com"; // send the form here $concerning = $_POST['concerning']; $name = $_POST['name']; $email = $_POST['email']; $address = $_POST['address']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $phone = $_POST['phone']; $student_type = $_POST['student_type']; $major = $_POST['major']; $information = $_POST['information']; $captcha = $_POST['captcha']; $errors .= (empty($concerning)) ? "<br />Please choose what this is concerning." : FALSE; $errors .= (empty($name)) ? "<br />Please fill in your name." : ""; $errors .= (empty($email)||!preg_match("/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*(([,]|[,])\s*\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*$/", $email)) ? "<br />Please fill in your email address." : FALSE; $errors .= (empty($student_type)) ? "<br />Please choose a student type." : FALSE; $errors .= (empty($captcha)||!(strtolower($captcha=="BUZZ"))) ? "<br />Please type the correct word." : FALSE; if (!$errors) { $msg = "Concerning: {$concerning}\nName: {$name}\nEmail: {$email}\nAddress: {$address}\nCity, State ZIP: {$city, $state $zip}\nPhone: {$phone}\nStudent Type: {$student_type}\nMajor: {$major}\nInformation: {$information}\n"; $headers .= "From: {$name} <{$email}>\r\n"; $subject = "The Advisor - Contact Form"; ini_set(sendmail_from, $email); $bool = mail($to, $subject, $msg, $headers); ini_restore(sendmail_from); if ($bool) { header("Location: thankyou.php"); exit; } else { DIE ("Something happened that wasn't supposed to. Please send an email to {$to} and tell me that you got this message."); } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709776 Share on other sites More sharing options...
rhodesa Posted December 8, 2008 Share Posted December 8, 2008 no syntax errors...try removing the ini_set/ini_restore stuff, as the FROM header should do the same same thing Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709788 Share on other sites More sharing options...
soycharliente Posted December 8, 2008 Author Share Posted December 8, 2008 Nope. I even tried leaving that in and taking out the $headers line. I've been using this bit of code for a while with no problems. This is really frustrating. Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709801 Share on other sites More sharing options...
premiso Posted December 8, 2008 Share Posted December 8, 2008 Do some debugging: if (!$errors) { echo 'here0'; $msg = "Concerning: {$concerning}\nName: {$name}\nEmail: {$email}\nAddress: {$address}\nCity, State ZIP: {$city, $state $zip}\nPhone: {$phone}\nStudent Type: {$student_type}\nMajor: {$major}\nInformation: {$information}\n"; $headers .= "From: {$name} <{$email}>\r\n"; $subject = "The Advisor - Contact Form"; echo 'here1'; ini_set(sendmail_from, $email); echo 'here2'; $bool = mail($to, $subject, $msg, $headers); echo 'here3'; ini_restore(sendmail_from); echo 'here4'; if ($bool) { echo 'here5'; header("Location: thankyou.php"); exit; } else { echo 'here6'; DIE ("Something happened that wasn't supposed to. Please send an email to {$to} and tell me that you got this message."); } } } ?> And see where it stops and go from there. Where it stops it means the line below is the culprit Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709808 Share on other sites More sharing options...
soycharliente Posted December 8, 2008 Author Share Posted December 8, 2008 I'm not submitting the form. I'm trying to get the initial page to load. The if isn't being executed. Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709814 Share on other sites More sharing options...
premiso Posted December 8, 2008 Share Posted December 8, 2008 Well theres your answer right there. The page will not load on it's own cause for the first if statement there is no else....try this: <?php if (isset($_POST['Submit']) && $_POST['Submit'] == "Submit") { foreach ($_POST as $key => $val) { $_POST[$key] = trim(stripslashes($val)); } $to = "xxx.xxx@xxx.com"; // send the form here $concerning = $_POST['concerning']; $name = $_POST['name']; $email = $_POST['email']; $address = $_POST['address']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $phone = $_POST['phone']; $student_type = $_POST['student_type']; $major = $_POST['major']; $information = $_POST['information']; $captcha = $_POST['captcha']; $errors .= (empty($concerning)) ? "<br />Please choose what this is concerning." : FALSE; $errors .= (empty($name)) ? "<br />Please fill in your name." : ""; $errors .= (empty($email)||!preg_match("/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*(([,]|[,])\s*\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*$/", $email)) ? "<br />Please fill in your email address." : FALSE; $errors .= (empty($student_type)) ? "<br />Please choose a student type." : FALSE; $errors .= (empty($captcha)||!(strtolower($captcha=="BUZZ"))) ? "<br />Please type the correct word." : FALSE; if (!$errors) { $msg = "Concerning: {$concerning}\nName: {$name}\nEmail: {$email}\nAddress: {$address}\nCity, State ZIP: {$city, $state $zip}\nPhone: {$phone}\nStudent Type: {$student_type}\nMajor: {$major}\nInformation: {$information}\n"; $headers .= "From: {$name} <{$email}>\r\n"; $subject = "The Advisor - Contact Form"; ini_set(sendmail_from, $email); $bool = mail($to, $subject, $msg, $headers); ini_restore(sendmail_from); if ($bool) { header("Location: thankyou.php"); exit; } else { DIE ("Something happened that wasn't supposed to. Please send an email to {$to} and tell me that you got this message."); } } }else { DIE("This was not submitted via a form, page is intentionally blank."); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709818 Share on other sites More sharing options...
soycharliente Posted December 8, 2008 Author Share Posted December 8, 2008 I'm pretty sure the HTML code outside the PHP tags will load. If the if statement is skipped over, the HTML should load. I don't need an else. But, to be sure, I added an else statement with an echo inside. Nothing was printed on the screen. Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709835 Share on other sites More sharing options...
premiso Posted December 8, 2008 Share Posted December 8, 2008 I'm pretty sure the HTML code outside the PHP tags will load. If the if statement is skipped over, the HTML should load. I don't need an else. But, to be sure, I added an else statement with an echo inside. Nothing was printed on the screen. I see. Well it seems you may have some issues with your server, or the file that is including the above file. Since this is being included I would not use the DIE for the else as it would kill the script always if post is not set, but to test the page itself by calling thatpage.php see if that die is printed, if it is than the problem lies on the other page. Can you post the code that includes the above file? Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709849 Share on other sites More sharing options...
soycharliente Posted December 8, 2008 Author Share Posted December 8, 2008 I'm not using an include statement. It's typed directly into the index.php page. When I try to hit the index page, nothing is printed. Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709854 Share on other sites More sharing options...
revraz Posted December 8, 2008 Share Posted December 8, 2008 Change header("Location: thankyou.php"); to a HTML or Javascript redirect and see if it works. Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709857 Share on other sites More sharing options...
soycharliente Posted December 8, 2008 Author Share Posted December 8, 2008 I used an HTML meta refresh. Still blank. I took out the DIE statement (someone mentioned something about the DIE statement possibly causing an issue). Still blank. Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709865 Share on other sites More sharing options...
premiso Posted December 8, 2008 Share Posted December 8, 2008 How about removing the exit statement? Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709866 Share on other sites More sharing options...
revraz Posted December 8, 2008 Share Posted December 8, 2008 Well there is definately an error somewhere, check your servers logs to see if it's being reported. Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709868 Share on other sites More sharing options...
soycharliente Posted December 8, 2008 Author Share Posted December 8, 2008 Removing exit didn't work. I've contacted the server admin and he's trying to get home to show me how to [insert something I didn't understand. Forcing to show errors in some way even if the page comes up blank. I think it's a test to determine if the code could possibly run. I have no idea.] But I seriously don't see any syntax errors. Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709871 Share on other sites More sharing options...
soycharliente Posted December 8, 2008 Author Share Posted December 8, 2008 I'm just going through each line and removing them one by one and in blocks to see what makes the page show. If I remove the entire if statement it works, so I'm trying to see if I can find one specific line. Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709875 Share on other sites More sharing options...
soycharliente Posted December 8, 2008 Author Share Posted December 8, 2008 When I delete this one line, the page comes up! <?php $msg = "Concerning: {$concerning}\nName: {$name}\nEmail: {$email}\nAddress: {$address}\nCity, State ZIP: {$city, $state $zip}\nPhone: {$phone}\nStudent Type: {$student_type}\nMajor: {$major}\nInformation: {$information}\n"; ?> Anyone see anything? Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709877 Share on other sites More sharing options...
soycharliente Posted December 8, 2008 Author Share Posted December 8, 2008 I found it. I'm stupid. Problem: {$city, $state $zip} Solution: {$city}, {$state} {$zip} Thanks for all the help. I'm sorry it WAS a syntax error! Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709881 Share on other sites More sharing options...
premiso Posted December 8, 2008 Share Posted December 8, 2008 ZIP: {$city}, {$state} {$zip} That part I do not think is right. Try replacing it with the above. EDIT: Dont feel too bad, I missed it too along with a few others =) Quote Link to comment https://forums.phpfreaks.com/topic/136111-solved-page-not-loading/#findComment-709883 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.