conker87 Posted July 18, 2011 Share Posted July 18, 2011 Alright. I've spent the last hour trying to figure out why my index page has stopped outputting anything. It just suddenly stopped without warning. The page index.php has a require() that gets the mysql stuff, etc. Ran on its own, the required file works fine and with the require on index.php commented out, index.php loads. I've added the display_errors with error_reporting to (E_ALL ^ E_NOTICE) at the beginning of the script but it's still outputting nothing but a blank screen. Has anyone got any ideas at all as to what it could be? The index page has barely any php at all bar some includes for pages and whatnot. Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/ Share on other sites More sharing options...
AyKay47 Posted July 18, 2011 Share Posted July 18, 2011 if you have set your error_reporting to E_ALL and error.log isn't reporting any errors that would cause this, please post the code of the file being required please Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244182 Share on other sites More sharing options...
conker87 Posted July 18, 2011 Author Share Posted July 18, 2011 <?php // Error reporting, since it doesn't seem to work in the sub domain error_reporting(E_ALL ^ E_NOTICE); ini_set("display_errors", '1'); // Start of the script $TIME_START_SCRIPT = time(); session_start(); date_default_timezone_set("Europe/London"); ini_set('session.gc_maxlifetime', 86400); // Requires // Database require("__functions_mysql.php"); ConnectToDB(); require("__functions_exploits.php"); require("__functions_db.php"); require("__functions_login.php"); require("__functions_misc.php"); require("__functions_social.php"); // Sanitise // GET and POST arrays. No need to sanitise SESSION and REQUEST, as SESSION values will have been sanitised before and REQUEST is not used. $_GET = filterParameters($_GET); $_POST = filterParameters($_POST); // Variables // Site options $options = mysql_fetch_array(mysql_query("SELECT * FROM options WHERE options.id = 1")); define(ENABLE_LOGIN, $options['ENABLE_LOGIN']); define(SHOW_TWITTER_FEED, $options['SHOW_TWITTER_FEED']); define(HITS_TIMEOUT, $options['HITS_TIMEOUT']); // URL $admin = (!empty($_GET['admin'])) ? $_GET['admin'] : null; $section = (!empty($_GET['section'])) ? $_GET['section'] : null; $search = (!empty($_GET['search'])) ? $_GET['search'] : null; $title = (!empty($_GET['title'])) ? $_GET['title'] : null; $id = (!empty($_GET['id'])) ? (int) $_GET['id'] : null; $er = (!empty($_GET['error'])) ? $_GET['error'] : null; Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244186 Share on other sites More sharing options...
teynon Posted July 18, 2011 Share Posted July 18, 2011 You either didn't post the entire file, or that file never ends PHP. (IE ?>) Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244187 Share on other sites More sharing options...
AyKay47 Posted July 18, 2011 Share Posted July 18, 2011 You either didn't post the entire file, or that file never ends PHP. (IE ?>) which will cause this file to work alone, however will cause an error is you include/require this file into another php file Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244190 Share on other sites More sharing options...
conker87 Posted July 18, 2011 Author Share Posted July 18, 2011 That's the entire file, there is a ?> at the end, I just forgot to take out the top <?php because I was already using the forum's php tags. Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244191 Share on other sites More sharing options...
teynon Posted July 18, 2011 Share Posted July 18, 2011 Out of curiosity.... How do you know the required file works fine by itself? It doesn't output anything. Second of all, can you post the code of the file you are calling it from (index). Are you sure you are referencing the correct file location? Post file structure / locations too please. Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244193 Share on other sites More sharing options...
conker87 Posted July 18, 2011 Author Share Posted July 18, 2011 Edit: Out of curiosity.... How do you know the required file works fine by itself? It doesn't output anything.It used to, I placed a 'echo "hello?";' at the bottom, it was cut off when I c/p into here. - Ok. I went through the require file and copy and pasted all bits from top to bottom and found that it was my ConnectToDB() function, then I found out that it was the mysql_connect() function. I'm running this off a subdomain, a testing area if you will. The part that breaks it is if I put in all the details into mysql_connect() then the file wont output, if I put in incorrect data it will output, but will error (rather ironically). I was running the SAME code for the last month or so through this subdomain, the ConnectToDB() function worked fine, up until when it broke not 2 hours ago. Would this be a hosting issue? Or is mysql_connect somehow become sentient and not willing to do my bidding? Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244196 Share on other sites More sharing options...
teynon Posted July 18, 2011 Share Posted July 18, 2011 Please post the relevant code. Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244199 Share on other sites More sharing options...
conker87 Posted July 18, 2011 Author Share Posted July 18, 2011 if (!mysql_connect("CORRECT_DATA", "CORRECT_DATA", "CORRECT_DATA")) { $error[] = "Unable to connect to the Database Server."; } if (!mysql_select_db("CORRECT_DATA")) { $error[] = "Unable to connect to the Database."; } Will cause the file to output nothing and show a blank page. Replacing the data with an incorrect host, username or password will cause the file to output correctly. Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244200 Share on other sites More sharing options...
teynon Posted July 18, 2011 Share Posted July 18, 2011 A bit of an odd question, but your username, database, and password doesn't contain any special characters that might be interpreted as something else by PHP? Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244201 Share on other sites More sharing options...
conker87 Posted July 18, 2011 Author Share Posted July 18, 2011 My username has an underscore and my password has a '#' as it was randomly generated. Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244203 Share on other sites More sharing options...
teynon Posted July 18, 2011 Share Posted July 18, 2011 I think there is something else going on that you're not seeing / telling us, but try changing the double quotes to single quotes " -> ' Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244205 Share on other sites More sharing options...
conker87 Posted July 18, 2011 Author Share Posted July 18, 2011 Nope. That didn't work. If I comment out the above code then my page outputs correctly, anything other than incorrect data or commenting it out causes lack of outputting. Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244206 Share on other sites More sharing options...
teynon Posted July 18, 2011 Share Posted July 18, 2011 Pop an or die(mysql_error()) on there. Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244208 Share on other sites More sharing options...
conker87 Posted July 18, 2011 Author Share Posted July 18, 2011 This is weird: mysql_connect('', '', '') or die(mysql_error()); mysql_select_db('') or die(mysql_error()); Also outputs nothing... I literally do not know what's going on. Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244209 Share on other sites More sharing options...
conker87 Posted July 18, 2011 Author Share Posted July 18, 2011 Now this is happening on the top level domain... Has mysql_connect been known to break like this? Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244221 Share on other sites More sharing options...
conker87 Posted July 18, 2011 Author Share Posted July 18, 2011 Right. It seems the host is having problems with it's migration of the MySQL server. Hilarious as it is, when the query is CORRECT and everything is in order: it makes the pages output null, while if something is wrong with a query (i.e. no table, query syntax incorrect, etc) then the page outputs just fine. Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244234 Share on other sites More sharing options...
DavidAM Posted July 18, 2011 Share Posted July 18, 2011 You either didn't post the entire file, or that file never ends PHP. (IE ?>) which will cause this file to work alone, however will cause an error is you include/require this file into another php file Just for the record (and any future readers), you do NOT have to close out of PHP at the end of an included (or required) file. If you DO close PHP ("?>"), and there is anything more than an immediately trailing newline, it will be considered data to be sent to the browser. This will cause the dreaded "Headers already sent" message when you try to send a header or start a session. Personally, I NEVER close out of PHP at the end of included files or page scripts. [ see the note at http://us.php.net/manual/en/language.basic-syntax.instruction-separation.php ] Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244323 Share on other sites More sharing options...
conker87 Posted July 19, 2011 Author Share Posted July 19, 2011 Alright. After hours of trudging through the code, I discover that it's my login functions being recursively called without a return. Thanks for the help everyone though! Quote Link to comment https://forums.phpfreaks.com/topic/242264-blank-indexphp/#findComment-1244829 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.