Hi,

I am having trouble with this page, it is completely blank. I have turned on error reporting but nothing happens, does anyone know what has happened to it? It has worked previously so maybe I have changed something but not sure what.

<?php
session_start();
ob_start();
if(!isset($_SESSION['authenticated']))
{ 
header ("Location: http://www.example.com") ;
 }
else
{
?>
<html>
<head>
<? include ("/home/example.com"); ?>
</head>

<body>

<div id="main">
     <?php include ("/home/example.com"); ?>
    <div id="content">
        <div id="info">

<?php 
$link = mysql_connect("","",""); 
if (!$link) { 
    die('Could not connect: ' . mysql_error()); 
} 
mysql_select_db(); 

$pagename=ereg_replace("[^A-Za-z0-9]", "", $bandname); 

$bandname = mysql_real_escape_string($_POST['bandname']);
$email = mysql_real_escape_string($_POST['email']);
$myspace = mysql_real_escape_string($_POST['myspace']);
$twitter = mysql_real_escape_string($_POST['twitter']);
$facebook = mysql_real_escape_string($_POST['facebook']);
$website = mysql_real_escape_string($_POST['website']);
$firstname = mysql_real_escape_string($_POST['firstname']);
$surname = mysql_real_escape_string($_POST['surname']);
$location = mysql_real_escape_string($_POST['location']);
$about = mysql_real_escape_string($_POST['about']);
$genre = mysql_real_escape_string($_POST['genre']);
$username = mysql_real_escape_string($username);
$pagename = mysql_real_escape_string($pagename);

$query = ("SELECT * FROM bands WHERE BandName = '$bandname'");

$result = mysql_query($query);

$num = mysql_num_rows($result);

if ($num == 0) {

$sql="INSERT INTO bands (BandName, Email, Myspace, Twitter, Facebook, Website, Firstname, Surname, Location, About, Genre, Username, PageName)
VALUES
('$bandname','$email','$myspace','$twitter','$facebook','$website','$firstname','$surname','$location','$about','$genre','$username','$pagename')";


if (!mysql_query($sql,$link))
  {
  die('Error: ' . mysql_error());
  }

header ("Location: http://www.example.com") ;


mysql_close($link);

}

else {
echo 'Sorry, there is already a band listed using that name, please try again with a different name or email help@unsignedgigs.co.uk.’;
include '/home/example.com';
}
}
?>
        </div>
        <div id="ad">
<?php include ("/home/example.com"); ?>
        </div>
        <div id="ad2">
<?php include ("/home/example.com"); ?>
        </div>
        <div id="footer">
<?php include ("/home/example.com"); ?>
        </div>
    </div>
</div>

</body>

</html>

Thanks for any help - I realise it isn't great code as well, but I am learning.

Is your PHP error log error free as well?
Echo out so text to see if you can determine where it is failing if the logs don't help you.
And what is that you are trying to include (home/example.com)? What file type is and what is it meant to do?

there are better sources for tracking errors. which are you using?

Thanks for the responses. Error log is empty as well.

The includes are for header, a new field to input data if first was incorrect and some adverts.

Could you explain what you mean by echo out please?

I have tried turning on error reporting but nothing happened, what is the best way to see errors?

Thanks again

Well, checking the error log is the best but if you need to you can use var_export or echo to output a string of text. If you can see that text when you run the page you know you at least got to that point.
echo 'here';
If you view the source of the page do you see anything? You're including home/example.com as both header elements and content of the page so what exactly is it? Is it possible that the page is constructing itself correctly and just happens to be empty?

Thanks for your help, I've narrowed the problem down to something within this part of the code:

$pagename=ereg_replace("[^A-Za-z0-9]", "", $bandname); 

$bandname = mysql_real_escape_string($_POST['bandname']);
$email = mysql_real_escape_string($_POST['email']);
$myspace = mysql_real_escape_string($_POST['myspace']);
$twitter = mysql_real_escape_string($_POST['twitter']);
$facebook = mysql_real_escape_string($_POST['facebook']);
$website = mysql_real_escape_string($_POST['website']);
$firstname = mysql_real_escape_string($_POST['firstname']);
$surname = mysql_real_escape_string($_POST['surname']);
$location = mysql_real_escape_string($_POST['location']);
$about = mysql_real_escape_string($_POST['about']);
$genre = mysql_real_escape_string($_POST['genre']);
$username = mysql_real_escape_string($username);
$pagename = mysql_real_escape_string($pagename);

$query = ("SELECT * FROM bands WHERE BandName = '$bandname'");

$result = mysql_query($query);

$num = mysql_num_rows($result);

if ($num == 0) {

$sql="INSERT INTO bands (BandName, Email, Myspace, Twitter, Facebook, Website, Firstname, Surname, Location, About, Genre, Username, PageName)
VALUES
('$bandname','$email','$myspace','$twitter','$facebook','$website','$firstname','$surname','$location','$about','$genre','$username','$pagename')";


if (!mysql_query($sql,$link))
  {
  die('Error: ' . mysql_error());
  }

header ("Location: http://www.example.com") ;


mysql_close($link);

}

else {
echo 'Sorry, there is already a band listed using that name, please try again with a different name or email help@example.co.uk.’;
include '/form.php';
}
}

Still can't spot the problem but I am at least getting closer...

Is the closing quote on line 43 the same in your code, because that could cause an issue.

The problem was something with this - no idea what it was, I wrote it out again and now it works perfectly, very odd.

else {
echo 'Sorry, there is already a band listed using that name, please try again with a different name or email help@example.co.uk.’;
include '/form.php';
}

Thanks for everyone's help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.