Jump to content

Blank index.php


conker87

Recommended Posts

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.

Link to comment
Share on other sites

<?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;

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

	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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.