orange08 Posted May 20, 2009 Share Posted May 20, 2009 recently, when i testing my php site, sometimes the page just load as blank page without anything(i experience it twice and both are happen after i just modify my php file and uploading to hosting)...so, i thought is my code error causing this...then, i just try to load the page again, then it load normally. so, anyone can tell me what's the error i experience here? Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/ Share on other sites More sharing options...
Maq Posted May 20, 2009 Share Posted May 20, 2009 Could be a multitude of errors, usually syntactical. Put this at the top of the pages that display blank right after your opening <?php tag: ini_set ("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-838180 Share on other sites More sharing options...
orange08 Posted May 21, 2009 Author Share Posted May 21, 2009 Could be a multitude of errors, usually syntactical. Put this at the top of the pages that display blank right after your opening <?php tag: ini_set ("display_errors", "1"); error_reporting(E_ALL); for testing purpose, while site development process, the above script is put on the top of every php file? and the script should put above session_start() or below session_start() because i was told that session_start() must put at the very beginning line of the php file? Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-838993 Share on other sites More sharing options...
MasterACE14 Posted May 21, 2009 Share Posted May 21, 2009 session_start() just needs to go before any output. is not valid <h1>Welcome!</h1> <?php session_start(); ?> is valid <?php session_start(); ?> <h1>Welcome!</h1> Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-839008 Share on other sites More sharing options...
orange08 Posted May 21, 2009 Author Share Posted May 21, 2009 session_start() just needs to go before any output. is not valid <h1>Welcome!</h1> <?php session_start(); ?> is valid <?php session_start(); ?> <h1>Welcome!</h1> but, what i meant is ini_set ("display_errors", "1"); error_reporting(E_ALL); not other code...is that the above code should put before session_start()? Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-839020 Share on other sites More sharing options...
Maq Posted May 21, 2009 Share Posted May 21, 2009 Put this at the top of the pages that display blank right after your opening <?php tag: Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-839045 Share on other sites More sharing options...
orange08 Posted May 21, 2009 Author Share Posted May 21, 2009 Put this at the top of the pages that display blank right after your opening <?php tag: sorry, i'm a bit poor in english, so not too sure what it meant? is that? <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); session_start(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-839049 Share on other sites More sharing options...
Maq Posted May 21, 2009 Share Posted May 21, 2009 Almost, the ini should be on a separate line. ini_set ("display_errors", "1"); error_reporting(E_ALL); session_start(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-839063 Share on other sites More sharing options...
orange08 Posted May 21, 2009 Author Share Posted May 21, 2009 Almost, the ini should be on a separate line. <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); session_start(); ?> ok, thanks a lot! when i try this, i found almost all my pages got error displayed... is that need to ensure all these errors are solved? as a newbie, till now i'm only know got such script to test for the error...so, really need more guidance in this case... and most of the error i get is like Notice: Use of undefined constant myvariable - assumed 'myvariable' in /home/mytest/domains/mytestsite.com/public_html/mylogin.php on line 61 some of 'myvariable' is used in my GET link... what's this error meant? and how can i debug it? thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-839075 Share on other sites More sharing options...
Maq Posted May 21, 2009 Share Posted May 21, 2009 Can I see that portion of the code? Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-839079 Share on other sites More sharing options...
BobcatM Posted May 21, 2009 Share Posted May 21, 2009 There is no way for someone to help you if you do not post your code for everyone to review. Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-839080 Share on other sites More sharing options...
orange08 Posted May 22, 2009 Author Share Posted May 22, 2009 Can I see that portion of the code? ok, this is the line of codes that create the error in my login page mylogin.php if (isset($_GET[loginfo])){ if($_GET[loginfo]==1){ session_destroy(); echo "<META HTTP-EQUIV='refresh' content='0;URL=mylogin.php'>"; } } and the above code will be called, when user click a link from another file to logout(this is code in another php file.) <a href="mylogin.php?loginfo=1">Logout</a> as i have mentioned, almost all errors i get is 'use of undefined constant...' so, i really need to know where my mistake has create such error...to debug all the files. thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-839573 Share on other sites More sharing options...
Maq Posted May 22, 2009 Share Posted May 22, 2009 The notices are stemming from your array, you need to put single quotes around the associative key. i.e.: $_GET['loginfo'] You should do this with all your POST, GET, and associative array values. Everything else looks fine to me. The notices are appearing because of the error reporting we turned on. Change that and tell me if the pages still turn up blank, like I said before, that usually means there's a syntax error somewhere. Do you get any other errors? (If that's not line 61 in mylogin.php, we need to see that and some surrounding code, before and after line 61.) Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-839600 Share on other sites More sharing options...
orange08 Posted May 22, 2009 Author Share Posted May 22, 2009 The notices are stemming from your array, you need to put single quotes around the associative key. i.e.: $_GET['loginfo'] You should do this with all your POST, GET, and associative array values. Everything else looks fine to me. The notices are appearing because of the error reporting we turned on. Change that and tell me if the pages still turn up blank, like I said before, that usually means there's a syntax error somewhere. Do you get any other errors? (If that's not line 61 in mylogin.php, we need to see that and some surrounding code, before and after line 61.) really thanks a lot! i have added single quote for some of the cases, and it solve the error. i need to check back all those error because it's quite a lot. here, got another kind of error, it's happen for my combox box, the error just appear inside the combo Notice: Undefined index: lang in C:\xampp\htdocs\myfolder\mypage.php on line 187>English Notice: Undefined index: lang in C:\xampp\htdocs\myfolder\mypage.php on line 188>Chinese and this is my line 187 and 188 <option value="English" <?php if($_SESSION['lang']=="English"){?>selected<?php } ?>>English</option> <option value="Chinese" <?php if($_SESSION['lang']=="Chinese"){?>selected<?php } ?>>Chinese</option> thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-839641 Share on other sites More sharing options...
Maq Posted May 22, 2009 Share Posted May 22, 2009 Before the select menu put this line in: $_SESSION['lang'] = (isset($_SESSION['lang'])) ? $_SERVER['lang'] : "English"; This will assign $_SESSION['lang'] to English if it is not set, if it is then it will stay the same. The error you were seeing was due to that session variable not being set, if you want the default selected language to be something else, then just change English to whatever you want. Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-839646 Share on other sites More sharing options...
fanfavorite Posted May 22, 2009 Share Posted May 22, 2009 I always turn notices like that off because they don't really effect anything. I believe you need to make it: if (isset($_SESSION['lang'])){ before the check of $_SESSION['lang']: <option value="English" <?php if (isset($_SESSION['lang'])){ if($_SESSION['lang']=="English"){?>selected<?php } } ?>>English</option> <option value="Chinese" <?php if (isset($_SESSION['lang'])){ if($_SESSION['lang']=="Chinese"){?>selected<?php } } ?>>Chinese</option> Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-839650 Share on other sites More sharing options...
fanfavorite Posted May 22, 2009 Share Posted May 22, 2009 Yeah what Maq said previously. I am a bit tired right now. Off to bed. Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-839652 Share on other sites More sharing options...
Maq Posted May 22, 2009 Share Posted May 22, 2009 I always turn notices like that off because they don't really effect anything. I believe you need to make it: I agree, but it's good to have them on for when developing on development environment. The notices won't cause fatal errors but could potentially cause other problems like you're seeing in your situation. In a live environment you don't want these turned on. The code I provided does effectively the same thing as fanfavorites, but mine will give you a default value, and is only 1 line Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-839661 Share on other sites More sharing options...
orange08 Posted May 22, 2009 Author Share Posted May 22, 2009 Before the select menu put this line in: $_SESSION['lang'] = (isset($_SESSION['lang'])) ? $_SERVER['lang'] : "English"; This will assign $_SESSION['lang'] to English if it is not set, if it is then it will stay the same. The error you were seeing was due to that session variable not being set, if you want the default selected language to be something else, then just change English to whatever you want. yup, your code again solve my problem...thanks! for the previous case about the blank page, do you think that is really my problem of not include single quote for my GET value? the blank page won't happen every time...for example, when i load the page and it turn up as blank, then i just click the refresh key of my browser, then the page just appear...so, is that the single quote problem will causing such problem? and for your information, the happen of the blank page that i experienced for a few times are happen just after i modify the php file and upload to the hosting. Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-839667 Share on other sites More sharing options...
Maq Posted May 22, 2009 Share Posted May 22, 2009 All the errors that you posted are just notices/warnings and will not cause a blank page. Blank pages are usually caused by, like I've said before, fatal syntax errors. Are there any actually errors? for example, when i load the page and it turn up as blank, then i just click the refresh key of my browser, then the page just appear...so, is that the single quote problem will causing such problem? No that wouldn't cause a blank page. It's hard to tell without looking at your code. Can you post your entire code? Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-839672 Share on other sites More sharing options...
orange08 Posted May 22, 2009 Author Share Posted May 22, 2009 All the errors that you posted are just notices/warnings and will not cause a blank page. Blank pages are usually caused by, like I've said before, fatal syntax errors. Are there any actually errors? so, will the fatal syntax errors displayed when the error_reporting is turned off? i get no error when the error_reporting is turned off last time... No that wouldn't cause a blank page. It's hard to tell without looking at your code. Can you post your entire code? but, the code is quite long and not only happen on 1 page. for your information, a few times happen on my login page and got another time, when i clicked a a href link to open an edit page but end up with open my login page as blank... so, which part of code i should provide to you? Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-839683 Share on other sites More sharing options...
orange08 Posted May 25, 2009 Author Share Posted May 25, 2009 i have a page that will be opened in new browser when a link in an sent email is clicked. for that page, i try to open it with IE, and always end up with open as blank page. but, if using mozilla, all of my test, only one fail, not a blank page but an error of connection interrupted...i just can't guess what's the problem? is my code problem? so, if i provide the code of this page here, is it useful for you expert to help me to track the error? thanks! Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-841523 Share on other sites More sharing options...
fanfavorite Posted May 26, 2009 Share Posted May 26, 2009 Sounds more like a server issue to me. I would get your system administrator or host to check the system logs and see what is happening. Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-842336 Share on other sites More sharing options...
orange08 Posted May 26, 2009 Author Share Posted May 26, 2009 Sounds more like a server issue to me. I would get your system administrator or host to check the system logs and see what is happening. but, how come happen on IE only? Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-842403 Share on other sites More sharing options...
fanfavorite Posted May 26, 2009 Share Posted May 26, 2009 IE is slower than most other browsers, so could be timing out at a certain point. I ran into a similar issue once where it randomly would display a blank page instead of loading the page. I contacted the host of the clients and they were able to resolve it. I can't remember exactly what the cause was though. Quote Link to comment https://forums.phpfreaks.com/topic/158926-load-as-blank-page/#findComment-842429 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.