Index page goes blank

Hi,

I set this site up partly in php sometime ago. The index page draws its main contents down from a database. Not all though, the template is created by html and css. About a month ago i went into it to check it and found the index page was just showing as a blank page. I could not find what was wrong with the code so I uploaded the index page again. This seemed to do the trick as the index page was now visible. It was also visible if i went back to it from other pages on the site. however after after another weeek i went back to it and it was blank again. I went through the same proccess and got it back. a week later the same problem. There is obviously quite a flaw here but I cant track it down. any ideas?

the website is www.louandelcats.co.uk

Below is the index page code and the function file:

<?php require_once("connect/connection.php"); 
include("includes/functions.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Home</title>



<script type="text/javascript" language="JavaScript1.2" src="menu.js"></script>
<style type="text/css">
<!--
.style3 {
	font-size: 12px;
	color: #000000;
}
.style4 {color: #FF0000}
.style5 {color: #008000}
.style6 {color: #808080}
-->
</style>
<link href="articles/content1.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
#Layer2 {
	position:absolute;
	width:200px;
	height:115px;
	z-index:4;
	left: 776px;
	top: 831px;
}
-->
</style>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-18301581-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
</head>

<body background="images/catchatstuff/orangeback.jpg" >
<div id="wrapper">
<div id="banner"><img src="images/catchatstuff/newbanner2.gif" align="left" alt="banner index" width="964" height="80" border="2" /></div>
<div id="ccbox"><img src="images/catchatstuff/catchatlogo3.gif" width="200" height="100" border="0" usemap="#Map" />
<map name="Map" id="Map"><area shape="rect" coords="12,9,187,93" href="phpbb/index.php" />
</map></div>
<div id="menu"><?php require("includes/addmenu.js");?></div> <div align="center" >
   
    <p ><script src="http://services.newsgator.com/ngws/headlines.aspx?uid=1118043&mid=6"></script></p>
</div>
<div id="marklogo"><a href="http://www.markets2000.co.uk"><img src="images/catchatstuff/design graphic.gif" alt="web site design by markets2000" width="127" height="60" border="0" usemap="#Map11" /></a>
<map name="Map11" id="Map11"><area shape="rect" coords="13,7,116,54" href="http://www.markets2000.co.uk" />
</map></div>
<div id="dataped"><img src="images/catchatstuff/pedhigh.gif" alt="This months highlight"  /></div>
   
<div id="mainarea">

<div id="contentind">  
    <div id="contentbox"><?php  tablerows(" ","intro", "4");?><div id="sig"><img src="images/catchatstuff/sig1.gif" alt="Louandel web master " width="135" height="43" /></div>
 </div><!--contentbox-->

<div class="contentbox">
  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="508" height="100">
    <param name="movie" value="images/catchatstuff/newflash.swf" />
    <param name="quality" value="high" />
    <embed src="images/catchatstuff/newflash.swf" width="508" height="100" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>
  </object>
</div><!--flash-->

<div id="half">
<div id="spotex"><img src="images/articleimage/streetcat.jpg" alt="Cat Care" width="293 height="42" style="float:right" />
  <?php  tablerows("topleft_tit","topleft_cont","4");?>
  <div id="Layer2"><img src="images/catchatstuff/lilel1.gif" width="141" height="93" /></div>
</div>
<div id="spotex"><img src="images/articleimage/catcare1.jpg" /><?php tablerows("botleft_tit","botleft_cont","4");
 ?>
</div>
</div>
<div id="half">
<div id="spotex"><?php tablerows("topright_tit","topright_cont", "4");
 ?></div>
<div id="spotex"><img src="images/articleimage/catandlap1.jpg" /><?php tablerows("botright_tit","botright_cont","4");?></div> 
 </div>
<div id="newindex"><img src="images/articleimage/articleask.gif" alt="Send in your own articles" width="480" height="90" border="0" usemap="#Map2" />
  <map name="Map2" id="Map2">
    <area shape="rect" coords="54,15,443,76" href="articles/articleRules.php" alt="Article rules" />
  </map>
  </div>
</div> <!-- contentind -->
<?php require("includes/index_footer.php");

The functions file:

<?php
/*---------------------------------------mysqli prep-------------------------------------------*/
function mysqli_prep($value){
global $connection;
$magic_quotes_active = get_magic_quotes_gpc();
$new_enough_php = function_exists("mysqli_real_escape_string");
if($new_enough_php){
if ($magic_quotes_active){ $value = stripslashes($value);}
$value = mysqli_real_escape_string($connection, $value);
}else{
if(!$magic_quotes_active){$value = addslashes($value);}
}
return $value;
}
/*--------------------------------------------------redirect--------------------------------*/
function redirect_to($location = NULL){
if($location != NULL){
header("Location:{$location}");
exit;
}
} 
/*------------------------------------------------------index page----------------------------*/
// indexpage
function tablerows($field, $field2, $id){
if(!$id){
	die;
	}
	global $connection;
$query = "SELECT * FROM cms_index WHERE id = $id";
$result = mysqli_query($connection, $query);
if(!$result){die("Database query failed".mysqli_error($connection));}
while($row = mysqli_fetch_array($result)){
echo $row[$field];
echo $row[$field2];
}
}
// this next line is for security. you should always be careful when you embed variables in sql.
// the action is a typecast and changes the variable to "int"
$id = isset( $_GET['id'] ) ? (int) $_GET['id'] : '';
/*---------------------------------------New function for index CMS---------------------------*/
function tablerows1($field, $id){
if(!$id){
	die;
	}
	global $connection;
$query = "SELECT * FROM cms_index WHERE id = $id";
$result = mysqli_query($connection, $query);
if(!$result){die("Database query failed".mysqli_error($connection));}
while($row = mysqli_fetch_array($result)){
echo $row[$field];
}
}
// this next line is for security. you should always be careful when you embed variables in sql.
// the action is a typecast and changes the variable to "int"
$id = isset( $_GET['id'] ) ? (int) $_GET['id'] : '';

// the following is for content for catcare, showcat and Kitten central
function careshowkit($field, $id){
if(!$id){
	die;
	}
	global $connection;
$query = "SELECT * FROM cms_careshowkit WHERE id = $id";
$result = mysqli_query($connection, $query);
if(!$result){die("Database query failed".mysqli_error($connection));}
while($row = mysqli_fetch_array($result)){
echo $row[$field];
}
}
// this next line is for security. you should always be careful when you embed variables in sql.
// the action is a typecast and changes the variable to "int"
$id = isset( $_GET['id'] ) ? (int) $_GET['id'] : '';


//the following is a function for pedigree
function pedigree($field,  $id){
if(!$id){
	die;
	}
	global $connection;
$query = "SELECT * FROM cms_pedigree WHERE id = $id";
$result = mysqli_query($connection, $query);
if(!$result){die("Database query failed".mysqli_error($connection));}
while($row = mysqli_fetch_array($result)){
echo $row[$field];
}
}
// this next line is for security. you should always be careful when you embed variables in sql.
// the action is a typecast and changes the variable to "int"
$id = isset( $_GET['id'] ) ? (int) $_GET['id'] : '';
/*---------------------------------------------linda image path--------------------------------*/
function image_path($field){
if(!$id){
	die;
	}
	global $connection;
$query = "SELECT * FROM photographs ";
$result = mysqli_query($connection, $query);
if(!$result){die("Database query failed".mysqli_error($connection));}
while($row = mysqli_fetch_array($result)){
echo $row[$field];
}
}

?>

thanks for your help

Have a look at your Apache error log which usually gets stored in the same folder where your index.php file sits, i have a feeling that your connection.php file is causing an error because it’s using require which unlike include won’t typically output an error on the page.

My knowledge of php is very basic. I have put up the most recent part of the error log below. could there be a problem here?

Fri Oct 14 08:57:21 2011] [notice] Apache/2.2.11 (Win32) PHP/5.2.6 configured -- resuming normal operations
[Fri Oct 14 08:57:21 2011] [notice] Server built: Dec 10 2008 00:10:06
[Fri Oct 14 08:57:21 2011] [notice] Parent: Created child process 2836
[Fri Oct 14 08:57:21 2011] [notice] Child 2836: Child process is running
[Fri Oct 14 08:57:21 2011] [notice] Child 2836: Acquired the start mutex.
[Fri Oct 14 08:57:21 2011] [notice] Child 2836: Starting 64 worker threads.
[Fri Oct 14 08:57:21 2011] [notice] Child 2836: Starting thread to listen on port 80.
[Fri Oct 14 08:58:44 2011] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
[Fri Oct 14 08:58:44 2011] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
[Fri Oct 14 08:58:44 2011] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
[Fri Oct 14 09:00:05 2011] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
[Fri Oct 14 09:00:06 2011] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
[Fri Oct 14 09:00:22 2011] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
[Sat Oct 15 17:07:03 2011] [warn] pid file C:/wamp/bin/apache/Apache2.2.11/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Sat Oct 15 17:07:04 2011] [notice] Apache/2.2.11 (Win32) PHP/5.2.6 configured -- resuming normal operations
[Sat Oct 15 17:07:04 2011] [notice] Server built: Dec 10 2008 00:10:06
[Sat Oct 15 17:07:04 2011] [notice] Parent: Created child process 2596
[Sat Oct 15 17:07:05 2011] [notice] Child 2596: Child process is running
[Sat Oct 15 17:07:05 2011] [notice] Child 2596: Acquired the start mutex.
[Sat Oct 15 17:07:05 2011] [notice] Child 2596: Starting 64 worker threads.
[Sat Oct 15 17:07:05 2011] [notice] Child 2596: Starting thread to listen on port 80.
[Sun Oct 23 22:49:12 2011] [warn] pid file C:/wamp/bin/apache/Apache2.2.11/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Sun Oct 23 22:49:13 2011] [notice] Apache/2.2.11 (Win32) PHP/5.2.6 configured -- resuming normal operations
[Sun Oct 23 22:49:13 2011] [notice] Server built: Dec 10 2008 00:10:06
[Sun Oct 23 22:49:13 2011] [notice] Parent: Created child process 4516
[Sun Oct 23 22:49:15 2011] [notice] Child 4516: Child process is running
[Sun Oct 23 22:49:15 2011] [notice] Child 4516: Acquired the start mutex.
[Sun Oct 23 22:49:15 2011] [notice] Child 4516: Starting 64 worker threads.
[Sun Oct 23 22:49:15 2011] [notice] Child 4516: Starting thread to listen on port 80.
[Sun Oct 23 22:50:37 2011] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/CFIDE
[Tue Nov 01 09:40:29 2011] [warn] pid file C:/wamp/bin/apache/Apache2.2.11/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Tue Nov 01 09:40:30 2011] [notice] Apache/2.2.11 (Win32) PHP/5.2.6 configured -- resuming normal operations
[Tue Nov 01 09:40:30 2011] [notice] Server built: Dec 10 2008 00:10:06
[Tue Nov 01 09:40:30 2011] [notice] Parent: Created child process 3856
[Tue Nov 01 09:40:31 2011] [notice] Child 3856: Child process is running
[Tue Nov 01 09:40:31 2011] [notice] Child 3856: Acquired the start mutex.
[Tue Nov 01 09:40:31 2011] [notice] Child 3856: Starting 64 worker threads.
[Tue Nov 01 09:40:31 2011] [notice] Child 3856: Starting thread to listen on port 80.

thanks for your help

The log you have posted looks more like the access log and not the error log because of the structure, because your using WAMP simply open C:/wamp/logs/apache_error.log which will by default catch PHP errors.

No, thats the error log. but i have only copied the last month or so to the post for obvious reasons.

Try turning on PHP error reporting. See the sticky http://www.sitepoint.com/forums/showthread.php?768872-Common-PHP-Problems

Do this on your local machine first in the hope that you discover what is causing the error, otherwise do it temporarily on your live server.

This is the error message that came up:

Notice: Undefined index: in C:\wamp\www\louandel3\includes\functions.php on line 33

However what does it mean by undefined index?

the line it is referring to I have put LINE 33 next it in the following code form the functions file

<?php
/*---------------------------------------mysqli prep-------------------------------------------*/
function mysqli_prep($value){
global $connection;
$magic_quotes_active = get_magic_quotes_gpc();
$new_enough_php = function_exists("mysqli_real_escape_string");
if($new_enough_php){
if ($magic_quotes_active){ $value = stripslashes($value);}
$value = mysqli_real_escape_string($connection, $value);
}else{
if(!$magic_quotes_active){$value = addslashes($value);}
}
return $value;
}
/*--------------------------------------------------redirect--------------------------------*/
function redirect_to($location = NULL){
if($location != NULL){
header("Location:{$location}");
exit;
}
} 
/*------------------------------------------------------index page----------------------------*/
// indexpage
function tablerows($field, $field2, $id){
if(!$id){
	die;
	}
	global $connection;
$query = "SELECT * FROM cms_index WHERE id = $id";
$result = mysqli_query($connection, $query);
if(!$result){die("Database query failed".mysqli_error($connection));}
while($row = mysqli_fetch_array($result)){
[B]echo $row[$field];[/B]LINE 33
echo $row[$field2];
}
}
// this next line is for security. you should always be careful when you embed variables in sql.
// the action is a typecast and changes the variable to "int"
$id = isset( $_GET['id'] ) ? (int) $_GET['id'] : '';
/*---------------------------------------New function for index CMS---------------------------*/
function tablerows1($field, $id){
if(!$id){
	die;
	}
	global $connection;
$query = "SELECT * FROM cms_index WHERE id = $id";
$result = mysqli_query($connection, $query);
if(!$result){die("Database query failed".mysqli_error($connection));}
while($row = mysqli_fetch_array($result)){
echo $row[$field];
}
}
// this next line is for security. you should always be careful when you embed variables in sql.
// the action is a typecast and changes the variable to "int"
$id = isset( $_GET['id'] ) ? (int) $_GET['id'] : '';

// the following is for content for catcare, showcat and Kitten central
function careshowkit($field, $id){
if(!$id){
	die;
	}
	global $connection;
$query = "SELECT * FROM cms_careshowkit WHERE id = $id";
$result = mysqli_query($connection, $query);
if(!$result){die("Database query failed".mysqli_error($connection));}
while($row = mysqli_fetch_array($result)){
echo $row[$field];
}
}
// this next line is for security. you should always be careful when you embed variables in sql.
// the action is a typecast and changes the variable to "int"
$id = isset( $_GET['id'] ) ? (int) $_GET['id'] : '';


//the following is a function for pedigree
function pedigree($field,  $id){
if(!$id){
	die;
	}
	global $connection;
$query = "SELECT * FROM cms_pedigree WHERE id = $id";
$result = mysqli_query($connection, $query);
if(!$result){die("Database query failed".mysqli_error($connection));}
while($row = mysqli_fetch_array($result)){
echo $row[$field];
}
}
// this next line is for security. you should always be careful when you embed variables in sql.
// the action is a typecast and changes the variable to "int"
$id = isset( $_GET['id'] ) ? (int) $_GET['id'] : '';
/*---------------------------------------------linda image path--------------------------------*/
function image_path($field){
if(!$id){
	die;
	}
	global $connection;
$query = "SELECT * FROM photographs ";
$result = mysqli_query($connection, $query);
if(!$result){die("Database query failed".mysqli_error($connection));}
while($row = mysqli_fetch_array($result)){
echo $row[$field];
}
}

?>

thanks for your help

it pretty much means that $filed is empty or null. or that the field its referencing is not in the array.
i dont see where you call tablerows($field, $field2, $id) can you post the relevant code that makes that function call?

for testing i would prob do
echo $field;
var_dump($row);
and see if the field you trying to refrence is in the array;

Below is the page where the function is called. When i first constructed the page it was based on the fact that for the articles I needed title and content, but for the intro to the page i only needed content. therefore i left the first (variable?) in the first call blank. this is obviously causing an error. Is there an easy way around it?

[/QUOTE]<div id=“contentind”>
<div id=“contentbox”><?php tablerows(" ",“intro”, “4”);?><div id=“sig”><img src=“images/catchatstuff/sig1.gif” alt="Louandel web master " width=“135” height=“43” /></div>
</div><!–contentbox–>

<div class=“contentbox”>
<object classid=“clsid:D27CDB6E-AE6D-11cf-96B8-444553540000” codebase=“http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0” width=“508” height=“100”>
<param name=“movie” value=“images/catchatstuff/newflash.swf” />
<param name=“quality” value=“high” />
<embed src=“images/catchatstuff/newflash.swf” width=“508” height=“100” quality=“high” pluginspage=“http://www.macromedia.com/go/getflashplayer” type=“application/x-shockwave-flash”></embed>
</object>
</div><!–flash–>

<div id=“half”>
<div id=“spotex”><img src=“images/articleimage/streetcat.jpg” alt=“Cat Care” width=“293 height=“42” style=“float:right” />
<?php tablerows(“topleft_tit”,“topleft_cont”,“4”);?>
<div id=“Layer2”><img src=“images/catchatstuff/lilel1.gif” width=“141” height=“93” /></div>
</div>
<div id=“spotex”><img src=“images/articleimage/catcare1.jpg” /><?php tablerows(“botleft_tit”,“botleft_cont”,“4”);
?>
</div>
</div>
<div id=“half”>
<div id=“spotex”><?php tablerows(“topright_tit”,“topright_cont”, “4”);
?></div>
<div id=“spotex”><img src=“images/articleimage/catandlap1.jpg” /><?php tablerows(“botright_tit”,“botright_cont”,“4”);?></div>
</div>
<div id=“newindex”><img src=“images/articleimage/articleask.gif” alt=“Send in your own articles” width=“480” height=“90” border=“0” usemap=”#Map2" />
<map name=“Map2” id=“Map2”>
<area shape=“rect” coords=“54,15,443,76” href=“articles/articleRules.php” alt=“Article rules” />
</map>
</div>
</div> <!-- contentind –>
<?php require(“includes/index_footer.php”);



thanks