Jump to content

Random Blank Page Output


legohalflife2man

Recommended Posts

Can someone please help me? I have a PHP file that used to work. I added something to it, but seeing that a blank page was outputted with that code in the file, I decided to remove that code from the file. But, once I saved the file and tried it again, I came up with the same problem - the output of the file was just a blank page with nothing for the source code. The file worked before, but after I added that code snippet and removed it, it just stopped working. Here is the file's full code:

 

<?php
define("IN_PHPBB", true);
$phpbb_root_path = (defined("PHPBB_ROOT_PATH")) ? PHPBB_ROOT_PATH : "../../forum/";
$phpEx = "php";
include($phpbb_root_path . "common." . $phpEx);
include($phpbb_root_path . "includes/functions_display." . $phpEx);
include($phpbb_root_path . "includes/functions_user." . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

$sql_error = "SELECT c_id, c_name FROM characters WHERE c_id=".$_GET['c'];
$result_error = mysql_query($sql_error) or die('Error 2: ' . mysql_error());
$row = mysql_fetch_array($result_error, MYSQL_ASSOC);
$c_error_id = $row['c_id'];
$c_title_name = $row['c_name'];
$cprofile = "S2";
if($c_error_id == "")
{
$page_id = "6.1";
$pagetype = "characters_noscroll";
include("../../internal/php/header.php");
?>

		<div class="full_width">
			<div id="p2" class="post bg2">
				<div class="inner"><span class="corners-top"><span></span></span>
				<div class="postbody" style="width:100%;">
					<h3 class="first">404 Error - Character Profile Not Found</h3>
					<div class="content">The character you are looking for either does not exist, or it was deleted by its creator or by a website moderator. Please try your search query again. If you are convinced that this is a bug with The Elder Stats, please report this bug on <a href="/forum">The Elder Stats forum</a>.<br /><br /><a href="/">Click here to go to Home.</a></div>
				</div>
				<div class="back2top"><a href="#top" class="top" title="Top">Top</a></div>
				<span class="corners-bottom"><span></span></span></div>
			</div>
		</div>
<?php
include("../../internal/php/footer.php");
}
else
{
$page_id = "6";
$page_s = "comments";
$pagetype = "characters";
include("../../internal/php/header.php");
include("../sidebar.php");
?>
		<div style="float: right;width: 724px;padding-top: 40px;">
			<div class="cpromain_bg"><br />
			    <div style="height:575px;width:710px;overflow:hidden;" class="makeScroll">
				<div class="cpromain_content"><br />
					<div style="clear: both;text-align: left;padding-left: 20px;padding-right: 10px;text-align: left;">
<?php
switch($_GET['mode'])
{
	case "post":
		if($user->data['is_registered'])
		{
			$com_content = $_POST['message'];
?>
						<script type="text/javascript" src="/forum/styles/prosilver/template/styleswitcher.js"></script>
						<script type="text/javascript" src="/forum/styles/prosilver/template/forum_fn.js"></script>
						<form id="postform" method="post" action="index.php?mode=submit&c=<?php echo $c_id; ?>">
<?php
			include("./post_body.php");
?>
						</form>
<?php
		}
		else
		{
			header("Location: ?c=".$c_id."#top);
		}
	break;
	case "submit":
		if($user->data['is_registered'])
		{
			$comcase = "submit";
			$submit = $_POST['submit'];
			$com_content = $_POST['message'];
			if($submit == "Preview")
			{
?>
						<script type="text/javascript" src="/forum/styles/prosilver/template/styleswitcher.js"></script>
						<script type="text/javascript" src="/forum/styles/prosilver/template/forum_fn.js"></script>
						<form id="postform" method="post" action="index.php?mode=submit&c=<?php echo $c_id; ?>">
						<div class="post bg2" id="preview">
							<div class="inner"><span class="corners-top"><span></span></span>
								<div class="postbody">
									<h3>Comment Preview:</h3>
									<div class="content"><?php echo $com_content; ?></div>
								</div>
							<span class="corners-bottom"><span></span></span></div>
						</div>
						<hr />
<?php
				include("./post_body.php");
?>
						</form>
<?php
			}
			elseif($submit == "Submit")
			{
				$com_author = $user->data['user_id'];
				$com_time = date("F j, Y, g:i a");
				$com_type = "cprofile";
				$com_articleid = $c_id;
				$bbcode_bitfield = "";
				$bbcode_uid = "";
				$sql = "INSERT INTO comments (com_author, com_time, com_type, com_articleid, com_content, bbcode_bitfield, bbcode_uid) VALUES ('$com_author', '$com_time', '$com_type', '$com_articleid', '$com_content', '$bbcode_bitfield', '$bbcode_uid')";
				mysql_query($sql) or die(mysql_error());
				$comid_sql = "SELECT com_id FROM comments WHERE com_author='$com_author' AND com_time='$com_time' AND com_type='$com_type' AND com_articleid='$com_articleid' AND com_content='$com_content' LIMIT 1";
				$comid_result = mysql_query($comid_sql) or die('Error : ' . mysql_error());
				$row = mysql_fetch_array($comid_result, MYSQL_ASSOC);
				$comid_temp_id = $row['com_id'];
				header("Location: ./?c=" . $c_id . "#com" . $comid_temp_id);
			}
			else
			{
				header("Location: ?mode=post&c=".$c_id);
			}
		}
		else
		{
			header("Location: ?c=".$c_id."#top);
		}
	break;
	case "edit":

	break;
	case "quote":

	break;
	case "delete":

	break;
	default:
		$sql_com = "SELECT com_id, com_author, com_time, com_lastedit, com_content, bbcode_bitfield, bbcode_uid FROM comments WHERE com_type='cprofile' AND com_articleid='$c_id' ORDER BY com_id DESC";
		$result_com = mysql_query($sql_com) or die('Error 3: ' . mysql_error());
		$numrows_com = mysql_num_rows($result_com);
		$com_id = $row['com_id'];
		$com_time = $row['com_type'];
		$com_lastedit = $row['com_lastedit'];
		$com_content = $row['com_content'];
		$bbcode_bitfield = $row['bbcode_bitfield'];
		$bbcode_uid = $row['bbcode_uid'];
		if($numrows_com == "0")
		{
?>
						<div class="topic-actions">
							<div class="buttons">
								<div class="reply-icon"><a href="?mode=post&c=<?php echo $c_id; ?>#top" title="Post a Comment"><span></span>Post a Comment</a></div>
							</div>
						</div>
						<div class="clear"></div>
						<hr class="divider" />
						<div id="p" class="post bg1">
							<div class="inner"><span class="corners-top"><span></span></span>
								<div class="postbody">
									<div class="content">No comments have been posted for this character. <a href="?mode=post&c=<?php echo $c_id; ?>#top">Be the first to post a comment!</a></div>
								</div>
								<div class="back2top"><a href="#top" class="top" title="Top">Top</a></div>
							<span class="corners-bottom"><span></span></span></div>
						</div>
						<div class="topic-actions">
							<div class="buttons">
								<div class="reply-icon"><a href="?mode=post&c=<?php echo $c_id; ?>#top" title="Post a Comment"><span></span>Post a Comment</a></div>
							</div>
						</div>
						<div class="clear"></div>
<?php
		}
		else
		{
			while($row = mysql_fetch_array($result_com, MYSQL_NUM))
			{
				list($com_id, $com_author, $com_time, $com_lastedit, $com_content, $bbcode_bitfield, $bbcode_uid) = $row;
?>
						<div class="topic-actions">
							<div class="buttons">
								<div class="reply-icon"><a href="?mode=post&c=<?php echo $c_id; ?>#top" title="Post a Comment"><span></span>Post a Comment</a></div>
							</div>
						</div>
						<div class="clear"></div>
						<hr class="divider" />
						<div id="com<?php echo $com_id; ?>" class="post bg<?php if($com_id&1){ echo "1"; }else{ echo "2"; } ?>">
							<div class="inner"><span class="corners-top"><span></span></span>
								<div class="postbody">
<?php
				if($user->data['is_registered'])
				{
					$sql_above = "SELECT com_id FROM comments WHERE com_type='cprofile' AND com_articleid='$c_id' AND com_id>'$com_id' AND com_author!='$com_author'";
					$result_above = mysql_query($sql_above);
					$numrows_above = mysql_num_rows($result_above);
?>
									<ul class="profile-icons">
<?php
					if($com_author == $user->data['user_id'] && $numrows_above == "0")
					{
?>
										<li class="edit-icon"><a href="./posting.php?mode=edit&f=8&p=42" title="Edit post"><span>Edit post</span></a></li>
										<li class="delete-icon"><a href="./posting.php?mode=delete&f=8&p=42" title="Delete post"><span>Delete post</span></a></li>
<?php
					}
					elseif(user_get_colour($user->data['user_id']) == $elder_council_color || user_get_colour($user->data['user_id']) == $bom_color)
					{
?>
										<li class="edit-icon"><a href="./posting.php?mode=edit&f=8&p=42" title="Edit post"><span>Edit post</span></a></li>
										<li class="delete-icon"><a href="./posting.php?mode=delete&f=8&p=42" title="Delete post"><span>Delete post</span></a></li>
<?php
					}
					if($com_author != $user->data['user_id'])
					{
?>
										<li class="report-icon"><a href="./report.php?f=8&p=42" title="Report this post"><span>Report this post</span></a></li>
<?php
					}
					if(user_get_colour($user->data['user_id']) == $elder_council_color || user_get_colour($user->data['user_id']) == $bom_color)
					{
?>
										<li class="warn-icon"><a href="./mcp.php?i=warn&mode=warn_post&f=8&p=42&sid=43a9357cc1df7f9676f36db0048f886c" title="Warn user"><span>Warn user</span></a></li>
<?php
					}
?>
										<li class="quote-icon"><a href="./posting.php?mode=quote&f=8&p=42" title="Reply with quote"><span>Reply with quote</span></a></li>
									</ul>
<?php
				}
?>
									<p class="author"><a href="#com<?php echo $com_id; ?>"><img src="/forum/styles/prosilver/imageset/icon_post_target.gif" width="11" height="9" alt="Post" title="Post" /></a>by <strong><a href="/members/<?php echo $com_author; ?>" style="color:#<?php echo user_get_colour($com_author); ?>;"><?php echo user_get_name($com_author); ?></a></strong> on <?php echo $com_time; ?></p>			
									<div class="content"><?php echo $com_content; ?></div>
								</div>
								<dl class="postprofile" id="profile<?php echo $com_id; ?>">
									<dt>
										<a href="/members/<?php echo $com_author; ?>"><img src="./download/file.php?avatar=60_1226097864.png" width="100" height="100" alt="User Avatar" /></a><br />
										<a href="/members/<?php echo $com_author; ?>" style="color:#<?php echo user_get_colour($com_author); ?>;" class="username-coloured"><?php echo user_get_name($com_author); ?></a>
									</dt>
									<dd>Elder Council Member</dd>
									<dd> </dd>
									<dd><strong>Posts:</strong> 20</dd><dd><strong>Joined:</strong> November 7th, 2008, 4:05 pm</dd>
									<dd>
										<ul class="profile-icons">
											<li class="pm-icon"><a href="./ucp.php?i=pm&mode=compose&action=quotepost&p=42" title="Private message"><span>Private message</span></a></li><li class="email-icon"><a href="mailto:[email protected]" title="E-mail"><span>E-mail</span></a></li>
										</ul>
									</dd>
								</dl>
								<div class="back2top"><a href="#top" class="top" title="Top">Top</a></div>
							<span class="corners-bottom"><span></span></span></div>
						</div>
						<div class="topic-actions">
							<div class="buttons">
								<div class="reply-icon"><?php if($user->data['is_registered']){ ?><a href="?mode=post&c=<?php echo $c_id; ?>#top" title="Post a Comment"><span></span>Post a Comment</a><?php } ?></div>
							</div>
						</div>
						<div class="clear"></div>
<?php
			}
		}
	break;
}
?>
					</div>
				</div>
			    </div>
			</div>
<?php
include("../tabs.php");
?>

		</div>

<?php
include("../../internal/php/footer.php");
}
?>

 

After removing some code here and there, I determined that the problem with the file lies in this area of the code:

 

      case "post":
         if($user->data['is_registered'])
         {
            $com_content = $_POST['message'];
?>
                     <script type="text/javascript" src="/forum/styles/prosilver/template/styleswitcher.js"></script>
                     <script type="text/javascript" src="/forum/styles/prosilver/template/forum_fn.js"></script>
                     <form id="postform" method="post" action="index.php?mode=submit&c=<?php echo $c_id; ?>">
<?php
            include("./post_body.php");
?>
                     </form>
<?php
         }
         else
         {
            header("Location: ?c=".$c_id."#top);
         }
      break;
      case "submit":
         if($user->data['is_registered'])
         {
            $comcase = "submit";
            $submit = $_POST['submit'];
            $com_content = $_POST['message'];
            if($submit == "Preview")
            {
?>
                     <script type="text/javascript" src="/forum/styles/prosilver/template/styleswitcher.js"></script>
                     <script type="text/javascript" src="/forum/styles/prosilver/template/forum_fn.js"></script>
                     <form id="postform" method="post" action="index.php?mode=submit&c=<?php echo $c_id; ?>">
                     <div class="post bg2" id="preview">
                        <div class="inner"><span class="corners-top"><span></span></span>
                           <div class="postbody">
                              <h3>Comment Preview:</h3>
                              <div class="content"><?php echo $com_content; ?></div>
                           </div>
                        <span class="corners-bottom"><span></span></span></div>
                     </div>
                     <hr />
<?php
               include("./post_body.php");
?>
                     </form>
<?php
            }
            elseif($submit == "Submit")
            {
               $com_author = $user->data['user_id'];
               $com_time = date("F j, Y, g:i a");
               $com_type = "cprofile";
               $com_articleid = $c_id;
               $bbcode_bitfield = "";
               $bbcode_uid = "";
               $sql = "INSERT INTO comments (com_author, com_time, com_type, com_articleid, com_content, bbcode_bitfield, bbcode_uid) VALUES ('$com_author', '$com_time', '$com_type', '$com_articleid', '$com_content', '$bbcode_bitfield', '$bbcode_uid')";
               mysql_query($sql) or die(mysql_error());
               $comid_sql = "SELECT com_id FROM comments WHERE com_author='$com_author' AND com_time='$com_time' AND com_type='$com_type' AND com_articleid='$com_articleid' AND com_content='$com_content' LIMIT 1";
               $comid_result = mysql_query($comid_sql) or die('Error : ' . mysql_error());
               $row = mysql_fetch_array($comid_result, MYSQL_ASSOC);
               $comid_temp_id = $row['com_id'];
               header("Location: ./?c=" . $c_id . "#com" . $comid_temp_id);
            }
            else
            {
               header("Location: ?mode=post&c=".$c_id);
            }
         }
         else
         {
            header("Location: ?c=".$c_id."#top);
         }
      break;

 

It just generates a blank output no matter what case I try to access in my web browser. I think part of my problem is that I have HTML above the PHP header() functions in the file, but I tried removing the HTML from above the header() functions in the file and I still got a blank output. Can someone please tell me what else I could be doing wrong? I would really appreciate it!

Link to comment
https://forums.phpfreaks.com/topic/138815-random-blank-page-output/
Share on other sites

Oh, I'm such an idiot! ;D

 

Thanks for your fast reply, ucffool, but before I even looked for replies on this topic, I found my stupid mistake.

 

This line:

            header("Location: ?c=".$c_id."#top);

Should have said this instead:

            header("Location: ?c=".$c_id."#top");

I forgot the double quote before the end parenthesizes in two places in the file. What a stupid mistake!

 

Anyway, thanks for your reply, but it was just a mess-up on my part.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.