# IE produces blank pages; IE bug or PHP code error?



## Thank The Cheese (Aug 15, 2006)

Hello everyone, 

I've just launched a website, but have just noticed a major problem in IE 6 (Windows XP version). Some links, when clicked on, produce a blank page. The user has to refresh the page in order to get it to load. I know this isn't the ideal forum for Windows-related issues, but as usual, the Mac browsers work fine!

I'm using PHP/MySQL on the site, so maybe that has something to do with it, but I can't put my finger on what it could be. After all, many other pages display fine, even through they use the same functions, database queries etc. I'm relatively new to PHP, so perhaps I'm doing something wrong. 

To check it out for youself, go to http://tomlongodesign.com/_folio/index.php. The links that produce a blank page are the "contact me" section and all of the print designs. 

Is this a known bug with IE? I don't think it's a PHP scripting problem because it works fine in all other browsers. 

In case it helps, here is the PHP code from the contact page:


```
<?php 
require_once ('../../connect_folio.php');

	if (isset($_POST['sendMessage']))
	{
	include ('modules/sendMail.inc');
	
	$feedback = sendMail( trim($_POST['name']), trim($_POST['email']), trim($_POST['phone']), trim($_POST['message']) );
	
	}


////////////////////////////////////////////////////////////////////
include ('modules/checkLogin.inc');
$section = 'contact me';
include ('components/header.inc');
////////////////////////////////////////////////////////////////////
?>

<div id="columnLeft">

	<div id="columnLeftTitle">


		<div class="tabTitleContainer"><h1>contact me</h1>
		</div>
		
				<div class="tabContainerWhite">

					<div class="tabWhite1">
					&nbsp;
					</div>

					<div class="tabWhite2">
					<p class="tabText">contact me</p>
					</div>

					<div class="tabWhite3">
					&nbsp;
					</div>

				</div>
				
	</div>

	<div class="itemPadded">

<?php

	if(isset($_POST['sendMessage']) && !$feedback)
	{
	
	echo '
	<h2>Thank you</h2>
	<p>Your message has been sent. Thank you for your input.</p>';
	
	} else {
	
		if($feedback)
		{
		echo '<p class="error"><strong>Errors occured while trying to send your message. </strong>';
		
			if($feedback['mysql'])
			{
			echo '<br />'.$feedback['mysql'];
			} 
			
			if($feedback['email'])
			{
			echo '<br />'.$feedback['email'];
			} 
			
			if($feedback['email'] || $feedback['mysql'])
			{
			echo 'This is probably due to a server error. If your message is urgent, please use the contact details in the column to the right, otherwise please try again later. Apologies for the inconvenience. ';
			} 
		
		echo '</p>';
		
		} else {
		echo '<div class="spacer">&nbsp;</div>';
		}
	
	echo'
	<form action="contact.php?style='.$style.'" method="post" enctype="multipart/form-data" id="message">

	<div class="label"><label for="name" >Name</label></div>	
	<div class="input"><input class="width100" type="text" name="name" id="name" size="25" maxlength="60" value="'; if($_POST['name']){ echo trim($_POST['name']); } else { echo 'Enter your name here.'; } echo '" />'; if($feedback['name']) { echo '<p class="error">'.$feedback['name'].'</p>'; } echo '</div>
	
	<div class="spacer">&nbsp;</div>
	
	<div class="label"><label for="phone">Phone (optional)</label></div>
	<div class="input"><input class="width100" value="'; if($_POST['phone']){ echo trim($_POST['phone']); } else { echo 'Enter phone number (optional)'; } echo '" type="text" name="phone" id="phone" size="25" maxlength="60" /></div>
	
	<div class="spacer">&nbsp;</div>
	
	<div class="label"><label for="email">E-Mail (optional)</label></div>
	<div class="input"><input class="width100" type="text" name="email" id="email" size="25" maxlength="60" value="'; if($_POST['email']){ echo trim($_POST['email']); } else { echo 'Enter email address (optional)'; } echo '" /></div>

	<div class="spacer">&nbsp;</div>

	<div class="label"><label for="comments">Your message</label></div>
	<div class="input"><textarea class="width100" name="message" id="message" cols="35" rows="8">'; if($_POST['message']){ echo trim($_POST['message']); } else { echo 'Please type your message here.'; } echo '</textarea>'; if($feedback['message']) { echo '<p class="error">'.$feedback['message'].'</p>'; } echo '</div>

	<div class="spacer">&nbsp;</div>

	<div class="label">&nbsp;</div>
	<div class="input"><input name="sendMessage" type="submit" id="sendMessage" value="Send Message" /></div>
			
	</form>';
	}

?>
	
	
	</div>



&nbsp;
</div>

<div id="columnRight">

	<div id="columnRightDark">

	<?php
	generateSwitcher();
	?>

	</div>

	<div class="columnRightContent">
	<h3>Phone</h3>
	<p>0411 950 801</p>
	
	<h3>Email</h3>
	<p><a class="blueLink" href="mailto:longo@internode.on.net">longo@internode.on.net</a></p>
	
	<h3>Post</h3>
	<p>30/10 Hallett Ave.<br />Tranmere, SA<br />5073</p>	
	</div>

</div>

	</body>
</html>
```



Thanks so much for the help!


----------



## HateEternal (Aug 16, 2006)

Interesting... Have you checked the server log for any PHP errors? You would think that even if there were some errors, if not at the very beginning, at least some html should come through.


----------



## Nummi_G4 (Aug 16, 2006)

I've seen certain elements not appearing in IE (due to floats with CSS) but never blank pages. Are you using floats anywhere?


----------



## HateEternal (Aug 16, 2006)

There isn't even any html... IE won't even open notepad for me when I try viewing the source.


----------



## Thank The Cheese (Aug 16, 2006)

Thanks for the replies guys. It's a strange one. 

I do use many floats in my CSS, but I don't think it's a CSS issue because, as HateEternal pointed out, it doesn't appear to load any CSS at all. 

The error log doesn't show anything related to contact.php or other problem pages. 

*EDIT:*
hmm, actualy, there are a couple of curious errors in the log that keep popping up whenever someone goes to my site:

```
[Wed Aug 16 18:19:58 2006] [error] [client <ip address removed>] File does not exist: /home/tlongo/public_html/favicon.ico
[Wed Aug 16 18:19:43 2006] [error] [client <ip address removed>] File does not exist: /home/tlongo/public_html/404.shtml
[Wed Aug 16 18:19:43 2006] [error] [client <ip address removed>] File does not exist: /home/tlongo/public_html/folio/style/global.css
[Wed Aug 16 22:18:26 2006] [error] [client <ip address removed>] File does not exist: /home/tlongo/public_html/robots.txt
```

anyone know what that means?

I tried experimenting last night by removing components one by one to see if it makes any difference. I *think* the problem lies in the header.inc and/or the global.inc:

*Header.inc*

```
<?php

include ('modules/global.inc');

$style = getStyle();

echo '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title>Tom Longo Design</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

	<style type="text/css"> 
	@import "styles/global.css"; 
	@import "styles/'.$style.'.css"; 
	</style>

	</head>
	<body>
<div class="hidden"><a href="#content">Skip primary navigation</a></div>

<div id="bannerContainer">

	<div id="bannerImage">
	
	<a href="index.php?style='.$style.'" title="Go to home page.">
	<img class="logo" src="images/logo.gif" alt="Tom Longo Design" />
	</a>

		<div class="topNavContainer">';

		generateTab ('portfolio', $section, $subSection, 'index.php?style='.$style);
		generateTab ('contact me', $section, $subSection, 'contact.php?style='.$style);
		
			if (isset($userID))
			{
			generateTab ($business.' profile', $section, $subSection, 'profile.php?style='.$style);
			}else{
			generateTab ('client login', $section, $subSection, 'login.php?style='.$style);
			}

			
		echo'
		</div>

	</div>
<a id="content"></a>
</div>
'; 

?>
```



*global.inc*

```
<?php

	function generateSwitcher($linkAppend = NULL)
	{

	echo '
	<form name="changeStyle" method="post" action="'.$_SERVER['PHP_SELF'].$linkAppend.'">
		
	<select name="style">
	<option value="null">Change style... (beta)</option>
	<option value="normal">Normal</option>
	<option value="large">Large Font Size</option>
	<option value="extra">Extra Large Font Size</option>
	<option value="contrast">High Contrast</option>
	</select>

	<input type="submit" name="changeStyle" if="changeStyle" value="Go" />

	</form>';

	}


	function getStyle()
	{
	
	$style = $_GET['style'];

		if(isset($_POST['changeStyle']))
		{
		$style = $_POST['style'];
		}

		if (!$style || $_POST['style']=='null') 
		{
		$style = 'normal';
		}
	
	return $style;
	
	}

	function generateGreenTab($label, $i, $show, $url)
	{
	
		if($i == $show)
		{
		echo '
		<div class="tabContainerWhite">

			<div class="tabWhite1">
			&nbsp;
			</div>

			<div class="tabWhite2">
			<p class="tabText">'.$label.'</p>
			</div>

			<div class="tabWhite3">
			&nbsp;
			</div>

		</div>';
		
		} else {
			
		echo '
		<div class="tabContainerGreen">

			<div class="tabGreen1">
			&nbsp;
			</div>

			<div class="tabGreen2">
			<p class="tabText"><a href="'.$url.'" title="Show '.$label.'">'.$label.'</a></p>
			</div>

			<div class="tabGreen3">
			&nbsp;
			</div>

		</div>';
		
		}
	
	}


	function generateTab($theTab, $theSection, $theSubsection, $url)
	{
	
		if($theTab == $theSection && $theSubsection != TRUE)
		{
		echo '
		<div class="mainTabContainer">
			
			<div class="mainTabGreen1">
			&nbsp;
			</div>
			
			<div class="mainTabGreen2">
			<p>'.$theTab.'</p>
			</div>
				
			<div class="mainTabGreen3">
			&nbsp;
			</div>

		</div>';
		} else {
		echo '
		<div class="mainTabContainer">
			
			<div class="mainTabBlue1">
			&nbsp;
			</div>
				
			<div class="mainTabBlue2">
			<p><a href="'.$url.'">'.$theTab.'</a></p>
			</div>
				
			<div class="mainTabBlue3">
			&nbsp;
			</div>

		</div>';
		}
	
	}

?>
```


What is also curious is that clicking on a Web or video design from the portfolio section never produces any problems, but clicking on a print design DOES produce a white screen -- yet both print and web designs are created using the same "showDesign.php" page. 

I also tried loading up contact.php in my browser, then copying the source and deleting all PHP code and replacing it with the HTML that the server outputs. When I do this it works, so clearly the problem has something to do with the PHP code, and not the HTML or CSS. 

?!?!

I've attached a zip file with the relevant files (contact.php, showDesign.php, CSS, global.inc, header.inc). I've had to resort to a warning page on my home page that tells the user the page won't display properly in some browsers, which isnt very professional.


----------



## HateEternal (Aug 17, 2006)

Are you sure you have PHP errors enabled? Also, I can't remember if they go into the apache log or if they go somewhere else.

You could set errors to be returned to the browser, it would be easier to detect when errors occur. I would suggest doing that in your test environment, unless you don't have this issue in test.

Because things don't work on the initial request, but do upon refresh, I'm wondering if IE is sending something goofy along in it's HTTP request. I also find it hard to believe that you aren't getting any errors.

As for the errors you posted:



> [Wed Aug 16 18:19:58 2006] [error] [client <ip address removed>] File does not exist: /home/tlongo/public_html/favicon.ico


This is the icon that shows next to the address, browsers always request this.


> [Wed Aug 16 18:19:43 2006] [error] [client <ip address removed>] File does not exist: /home/tlongo/public_html/404.shtml


The file not found page is not found!


> [Wed Aug 16 18:19:43 2006] [error] [client <ip address removed>] File does not exist: /home/tlongo/public_html/folio/style/global.css


shouldn't it be style*s*/global.css? Per 
	
	



```
@import "styles/global.css";
```



> [Wed Aug 16 22:18:26 2006] [error] [client <ip address removed>] File does not exist: /home/tlongo/public_html/robots.txt


This is the file that search engines request for keywords and such.


----------



## HateEternal (Aug 17, 2006)

You really should validate parameters before stuffing them into queries. I know it's a pain but people can do bad things to your database/site if you don't. I would read up on SQL Injection.

See the attached image for a basic example of what happens when I put in an invalid number. Your site probably has magic quotes on, which helps some, but validation is important!


----------



## Thank The Cheese (Aug 18, 2006)

thanks for the help hateEternal, and good point about validating parameters; something I hadn't even thought about 

I think I may have figured out what code is causing the problem. It's the code to check whether or not the user has logged in (whenever I remove the code, the problem goes away):


```
session_name('YourSessionID');
	session_set_cookie_params(3200);
	session_start(); 
	
	if (isset($_SESSION['userID']))
	{
	$userID = $_SESSION['userID'];
	$username = $_SESSION['username'];
	$business = $_SESSION['business'];
	$goTo = $_SESSION['goTo'];
	} else if (isset($_COOKIE['userID'])) {
	$userID = $_COOKIE['userID'];
	$username = $_COOKIE['username'];
	$business = $_COOKIE['business'];	
	$goTo = $_COOKIE['goTo'];
	}
```

..the reason I check for both cookies and sessions separately is because the user has the option to check a "remember me" box that stores a permanent cookie in their browser so they don't have to log in every couple of hours. 

I'm pretty new to the world of cookies and sessions, so it wouldn't surprise me if my code is sloppy. 

Big thanks to hateEternal -- it was your advise that led me to the discovery by changing error reporting modes. 


*EDIT:*
I'm almost certain that's the problem now. I've set up a mirror on my server with the session/cookie stuff removed and it seems to be fine. I'd love it if someone else could check to confirm (contact.php is the page I have been testing on, as well as the Reviver DVD cover design in the print section):

http://tomlongodesign.com/folio/index.php


----------



## billbaloney (Aug 18, 2006)

FYI, 

1. You have a bad declaration in normal.css:


```
a.designTitle
	{
	font-size: 95	%;
	}
```

The space between "95" and "%".

2. Your code doesn't validate as strict XHTML.  IE can actually be a stickler about this, so it is beneficial to fix the code problems before debugging in other ways.

Try changing your DTD to XHTML Transitional and re-validating (after you fix the "if"/"id" typo on the folio index page).

3. Two copy typos I noticed: "hIs" in the description for "The Chase", and "rediculous" in the description for "My Big Fat List".

4. Re: HateEternal's suggestion that you turn on error code: just remember that his point is to do this when testing or developing, and not on the live site.  It's easy to forget to take this kind of code out of the site when taking pages live.


----------

