Jump to content

Recommended Posts

I've stuffed up something, Its really bad, My whole sub folder on my website isnt working anymore. I am recieving this error from firefox on every single page:

The page isn't redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

    *  This problem can sometimes be caused by disabling or refusing to accept

          cookies.

 

I dont know what I've done, I've uploaded my backup of the subfolder that I made about half an hour before it went down. And the rest of my website works fine, its just this one folder. I have tried deleting my cookies and cache also with no success.

 

Any help, suggestions or information on this error is greatly appreciated!

 

Regards ACE

Link to comment
https://forums.phpfreaks.com/topic/71149-solved-ive-stuffed-up-big/
Share on other sites

I just downloaded the error log via FTP, and here are the last entries before the website went down.

 

[29-Sep-2007 05:22:08] PHP Fatal error:  Cannot redeclare player_session() (previously declared in /home/ace/public_html/conflictingforces/functions.php:7) in /home/ace/public_html/conflictingforces/functions.php on line 4

[29-Sep-2007 05:23:00] PHP Fatal error:  Cannot redeclare player_session() (previously declared in /home/ace/public_html/conflictingforces/functions.php:7) in /home/ace/public_html/conflictingforces/functions.php on line 4

[29-Sep-2007 05:23:43] PHP Fatal error:  Cannot redeclare player_session() (previously declared in /home/ace/public_html/conflictingforces/functions.php:7) in /home/ace/public_html/conflictingforces/functions.php on line 4

[29-Sep-2007 05:24:45] PHP Fatal error:  Cannot redeclare player_session() (previously declared in /home/ace/public_html/conflictingforces/functions.php:7) in /home/ace/public_html/conflictingforces/functions.php on line 4

You're declaring session_start() more than once.  This can happen if you have it in multiple files and then include them together in the same file.  Either put it in a completely separate file and use require_once() to ensure it doesn't get repeated or only use it in the final file (ie. the one the user views).

session_destroy(); is the 10th line, but Im posting the whole function anyway.

<?php // conflicting forces functions

// Put this at the top of pages you need to be logged into
function player_session() {

// Check whether the player id variable has been set, if it hasn't, log them out
if (!isset($_SESSION['playerid'])) {

// Destroy the session
session_destroy();

// Automatically redirect to the homepage
header("Location: index.php?page=home");

}	

};

So does "index.php?page=home" make a called to player_session (without setting session_start and/or setting $_SESSION['playerid'])?

 

if so then thats the loop ie

 

1. load "index.php?page=home"

2. thats calls player_session

3. which redirect to index.php?page=home

4. goto 1

thats the thing though, I have session_start() on index.php as thats the main file that runs the whole website. I also have ob_start() straight after session_start() so the header()'s work on every page. The player_session() is for pages the person has to be logged into to view. home.php has a form to log people in, that form is then sent to login.php which sets the playerid session variable if it was a valid account from my MySQL database. If not, then it die()'s and the person is redirected back to home.php

 

So I dont know whats stuffed up here  :-\ everything was working fine before, the last thing I was doing before it went down was creating variables for selecting columns from my database, and that was working fine. I went back and check the last few I set before it went down, and their is no typo's.

 

 

after commenting out player_session() at the top of leftnav.php (left panel on my website) The website is now back up. But, the only thing being displayed on the page is the background image, and the header. And their is a Fatal Error:

Fatal error: Call to undefined function: player_table() in /home/ace/public_html/conflictingforces/leftnav.php on line 14

 

Im looking into it now.

try this (for testing)

<?php // conflicting forces functions

// Put this at the top of pages you need to be logged into
function player_session() {

// Check whether the player id variable has been set, if it hasn't, log them out
if (!isset($_SESSION['playerid'])) {

// Destroy the session
session_destroy();

// Automatically redirect to the homepage
//header("Location: index.php?page=home");
die("Failed: <a href='index.php?page=home'>Home</a>");
}	

};

 

 

also post the first 20 or so lines of leftnav.php

I just change where I had commented out in leftnav.php from this:

<?php

/* includes */  /*
include '/home/ace/public_html/conflictingforces/functions.php';
include '/home/ace/public_html/conflictingforces/variables.php';

player_session();  */

 

to this:

<?php

/* includes */  
include '/home/ace/public_html/conflictingforces/functions.php';
include '/home/ace/public_html/conflictingforces/variables.php';
/*
player_session();  */

 

and the website is down again.

as soon as I comment out the functions.php include, the website is back up with the Fatal Error and only the header and background image. But once I remove the commenting, the website is back down again  :-[

 

here's all of leftnav.php

<?php

/* includes */  
//include '/home/ace/public_html/conflictingforces/functions.php';
include '/home/ace/public_html/conflictingforces/variables.php';

player_session();  

/**********************/
// Player Select Variables //
/**********************/

// Turns (cronjob related selects)
$player_ammo = player_table("ammo");
$player_bank = player_table("bank");
$player_money = player_table("money");
$player_currenthealth = player_table("currenthealth");
$player_maxhealth = player_table("maxhealth");
$player_currentpower = player_table("currentpower");
$player_maxpower = player_table("maxpower");


?>

<div id = "nav">

Navigational Panel<br>
<hr>
<?php 

$date=date(U); // format date for calculation in seconds
//print ("$date");  //if you want to see the date format now
$hourdiff = "16"; //change the server time plus sixteen hours
$timeadjust = ($hourdiff * 60 * 60); //this is how to calc it
$adjtime = date("M j, H:i", $date + $timeadjust); //format display
print $adjtime;  //print the adjusted time

?>
<hr>
<br>

<?php
// Use $HTTP_SESSION_VARS with PHP 4.0.6 or less
if (!isset($_SESSION['playerid'])) {
?>


<a href="index.php?page=home">Home</a><br>
<a href="index.php?page=progress">Progress</a><br>
<a href="index.php?page=encyclopedia">Encyclopedia</a><br>
<a href="index.php?page=support">Support</a><br>
<a href="http://www.crikeygames.com.au/forum/">Forum</a><br><br>

<?php
// Use $HTTP_SESSION_VARS with PHP 4.0.6 or less
}
if (isset($_SESSION['playerid'])) {
?>

<a href="index.php?page=base">Base</a><br>
<a href="index.php?page=inventory">Inventory</a><br>
<a href="index.php?page=encyclopedia">Encyclopedia</a><br>
<a href="index.php?page=support">Support</a><br>
<a href="index.php?page=logout">Logout</a><br><br>

<hr>
Ammo: <?php echo $player_ammo; ?><br>
Money: <?php echo $player_money; ?><br>
Bank: <?php echo $player_bank; ?><br>
Health: <?php echo $player_currenthealth; ?>/<?php echo $player_maxhealth; ?><br>
Power: <?php echo $player_currentpower; ?>/<?php echo $player_maxpower; ?>
<hr>

<?php } ?>





</div>

 

 

the die() function didnt make a difference, nor did include_once  :-\

 

The last change I made to leftnav.php before my website went down, was adding player_session() function to the top of it, just after the include()'s. I dont know if maybe its stuffed up the session variables or something.

 

Im really tired, I gotta hit the sack, please post any new information, ideas or suggestions you may have. Im checking this post first thing in the morning.(in about 9 hours time, I live in Sydney ^^ )

 

Regards ACE ps. Thanks for all the help you have given me so far :) , I only hope we can resolve this issue :/

I'll quickly post the Main pages for my website, so you got something to work with.

 

index.php

<?php
session_start();
ob_start(); 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!--<link rel = "stylesheet" title = "CF Layout" type = "text/css" href = "css/page-layout.css" > -->
<?php

// Include's
include('variables.php');
echo $meta;
?>
<style type="text/css">
<!--
/* set margins, padding, and inline-level alignment */
body,div {color:#FFFFFF; margin: 1px; padding: 0; background-color:#000000;font-family:Verdana, Arial, Helvetica, sans-serif; font-size: 100%}

/* XXXXXXXXXXXXXX table properties XXXXXXXXXXXXXXXXXX */

/* set table properties */
#progress, #encyclopedia table { border: 1px solid green; text-align: center }
#progress, #encyclopedia td { border: 1px solid lime; background: black }

/* set table width and margin */
#progress, #encyclopedia table { width: 500px ; caption-side: top;
            margin-bottom: 20px;  }

/* compute column widths regardless of cell content */
#progress, #encyclopedia table.fix { table-layout: fixed }

/**********************************************************************/
/* set table properties for other pages */
/**********************************************************************/

/* set table properties */
table { border: 1px solid lime;  }
td { border-bottom: 1px solid green; }

/* set table width and margin */
table { width: 380px;  }

/* compute column widths regardless of cell content */
table.fix { table-layout: fixed }

/* XXXXXXXXXXXXXXXXX table properties XXXXXXXXXXXXXXXX */

/* drop down box properties */
select { border: 1px solid lime; color: white; text-align: center; background: black }
option { border: 1px solid green; color: white; text-align: center; background: black }

/* input properties */
input { font: 12px verdana;}
input { background-color:#000000;border-style:outset;
border-color:lime; color:white;cursor:hand;} 

/* fieldsets and legends properties */
fieldset { border:1px solid green }
legend {
  padding: 0.2em 0.5em;
  border:1px solid lime;
  color:white;
  font-size:90%;
  text-align:right;
  }

/* set background image */
body {background-image:url(http://www.crikeygames.com.au/conflictingforces/images/CrickeyGames%20Wallpaper%20Plate%20Camo.jpg);}

/* spacing */
span  { word-spacing: 30px }

/* set widths and float nav & ads div content boxes */
#nav	{ float: left; width: 10%	}
#ads	{ float: right; width: 16% }

/* set side txt margins 5px > nav & ads widths */
#txt	{ margin-left: 105px; margin-right: 105px }
#progress { margin-left: 105px; margin-right: 105px }
#base { margin-left: 105px; margin-right: 105px } 
#home { margin-left: 105px; margin-right: 105px }
#encyclopedia { margin-left: 105px; margin-right: 105px }

/* set text aligns */
#hdr, #nav, #ads , #home { text-align: center }

/* ensure footer stays at the bottom */
#ftr	{ clear: both }

/* create 2 columns */
#leftcolumn { float: left; width: 380px; }
#rightcolumn { float: right; width: 380px; }

/* show boundaries and set image sizes - for clarity */
#hdr, #ftr, #nav, #ads	{ background-color:#1a1b16; border: groove #78AB46}
#home { background-color: #1a1b16; }
#base { background-color: #1a1b16; }
/*#leftcolumn { background-color: #1a1b16; }*/
/*#rightcolumn { background-color: #1a1b16; }*/
#progress { background-color:transparent;}
#encyclopedia { background-color:transparent; }
#txt	{ background-color:transparent;}
#hdr {width: 520px; height: 148px}
/* #hdr h1{display:none;margin:0; padding:0} */
/*#ads img		{ width: 120px; height: 500px	} */
/*#txt img		{ width: 150px; height: 200px	} */

/* set link colors */
#ads href		{ color: #00FF00}

/* set left nav properties */
a:link, a:visited	{background-color: #FFFF00; color:#000000; font-size:.95em; font-family: Arial, Helvetica, sans-serif}  
a:hover, a:active	{background-color: #FFFF00; color: #FFFF00; font-size:.95em; font-family: Arial, Helvetica, sans-serif} 
ul.circle {/*margin: 5px; padding-left: 0;*/list-style-type: circle; }
-->
</style>
<title><?=$gamename?> - Online MMORPG</title>
</head>
<body>
<?php
include('head.php');
?>
<?php
include('leftnav.php');
?>
<?php
include('rightnav.php');
?>

<?php
	switch ($_GET['page']) {
		default:
		case "home":
			require_once ("lib/home.php");
			break;
		case "progress":
			require_once ("lib/progress.php");
			break;
		case "support":
			require_once ("lib/support.php");
			break;
		case "encyclopedia":
			require_once ("lib/encyclopedia.php");
			break;
		case "encyclopedia_search":
			require_once ("lib/encyclopedia_search.php");
			break;
		case "base":
			require_once ("lib/base.php");
			break;
		case "login":
			require_once ("lib/login.php");
			break;
		case "logout":
			require_once ("lib/logout.php");
			break;
	}// end switch
?>



<?php
include('footer.php');
?>
</body>
</html>

variables.php

<?php // Game Variables for various things

// Important Information
$gamecreator = "ACE";
$gameproducer = "Crikey Games";
$gamename = "Conflicting Forces - Modern Combat";
$version = "0.1";

// Encyclopedia
$encyclopedia_version = "0.4";

// Meta

$meta = '<meta name = "creator" 
	content = "ACE" >
<meta name = "keywords"
	content = "Online,MMORPG,game,fun,crazy,roleplay" >
<meta name = "description"
	content = "Conflicting Forces is a MMORPG" >
<meta http-equiv = "Content-Type"
	content = "text/html; charset = ISO-8859-1" >';


?>

functions.php

<?php // conflicting forces functions

// Put this at the top of pages you need to be logged into
function player_session() {

// Check whether the player id variable has been set, if it hasn't, log them out
if (!isset($_SESSION['playerid'])) {

// Destroy the session
session_destroy();

// Automatically redirect to the homepage
//header("Location: index.php?page=home");
die("Failed: <a href='index.php?page=home'>Home</a>");
}	

};


// Select fields from the user table
function player_table($select) {
if (!isset($_SESSION['playerid'])) {

// Destroy the session
session_destroy();

// Automatically redirect to the homepage
header("Location: index.php?page=home");
}

$where = $_SESSION['playerid'];

$rs = mysql_connect( "localhost", "ace_ACE", "shadow69" );
$rs = mysql_select_db( "ace_cf" );

// SQL query for all entries in descending order
$sql = "SELECT `" . $select . "` FROM `cf_users` WHERE `id`='" . $where . "' LIMIT 1";
$rs = mysql_query( $sql ) or die('Query:<br />' . $sql . '<br /><br />Error:<br />' . mysql_error());

// This gets the data from the result resource
$query = mysql_result($rs,0,0);

return $query;

};

?>

 

login.php

<?php  // Login the Player

// Process the POST variables
$username = $_POST["username"];

// Setup the session variables
$_SESSION['username'] = $username;

// Connect to database ready to match the usernames, then switch over to match the ID
$rs = mysql_connect( "localhost", "ace_ACE", "*****" );
$rs = mysql_select_db( "ace_cf" );

// SQL query for all entries in descending order
$sql = "SELECT `id` FROM `cf_users` WHERE `username`='" . $username . "' LIMIT 1";
$rs = mysql_query( $sql ) or die('Query:<br />' . $sql . '<br /><br />Error:<br />' . mysql_error());

// This gets the data from the result resource
$query = mysql_result($rs,0,0);

// Put the players ID into a variable
$player_id = $query;

if ($player_id == '' || $player_id == ' ') {

// Tell them to enter a correct username, password and e-mail
die ("<center><br><br><b>You need to enter a Correct Username, Password and E-mail</b><br>
<input type=button value=\"Back\" onClick=\"history.go(-1)\"></center>
");

}

else {

// Put the players ID variable into a session variable
$_SESSION['playerid'] = $player_id;

// Start the output buffer so we dont create any errors with headers
ob_start();

// Automatically redirect the player to the base page
header("Location: index.php?page=base");

// End ob
ob_end_flush();

}



?>

 

logout.php

<?php // Logout Player - Destroy Session

// Destroy the session
session_destroy();

// Start the output buffer so we dont create any errors with headers
ob_start();

// Automatically redirect the player to the homepage
header("Location: index.php?page=home");

//Flush the buffer to screen
ob_end_flush();


?>

 

alright, Im off to get some sleep, back tommorow morning. cyas later

Hummm, the die should of stopped the inf. loop

i assume you commented out the header as well!

 

also change

 

function player_table($select) {
if (!isset($_SESSION['playerid'])) {

// Destroy the session
session_destroy();

// Automatically redirect to the homepage
header("Location: index.php?page=home");
}

 

to

function player_table($select) {
if (!isset($_SESSION['playerid'])) {

// Destroy the session
session_destroy();

// Automatically redirect to the homepage
//header("Location: index.php?page=home");
die("Failed #2: <a href='index.php?page=home'>Home</a>");
}

 

i'm also a little confused over the logout scipt.. as you say "index.php?page=home" redirects to logout yet the script also redirects their!

that second die, makes the website load, but only loads the header, and background image like before, but this time instead of getting a Fatal Error message, Im getting this in the leftnav:

Failed #2: Home

 

So thats stopping the loop. But where is the actual loop coming from?  ???

 

ps. now im really getting to bed lol, night.

maybe update

 

<?php

/* includes */  
if (isset($_SESSION['playerid']))
{
include '/home/ace/public_html/conflictingforces/functions.php';
include '/home/ace/public_html/conflictingforces/variables.php';

player_session();  
}

/**********************/
// Player Select Variables //
/**********************/

// Turns (cronjob related selects)
$player_ammo = player_table("ammo");
$player_bank = player_table("bank");
$player_money = player_table("money");
$player_currenthealth = player_table("currenthealth");
$player_maxhealth = player_table("maxhealth");
$player_currentpower = player_table("currentpower");
$player_maxpower = player_table("maxpower");


?>

<div id = "nav">

Navigational Panel<br>
<hr>
<?php 

$date=date(U); // format date for calculation in seconds
//print ("$date");  //if you want to see the date format now
$hourdiff = "16"; //change the server time plus sixteen hours
$timeadjust = ($hourdiff * 60 * 60); //this is how to calc it
$adjtime = date("M j, H:i", $date + $timeadjust); //format display
print $adjtime;  //print the adjusted time

?>
<hr>
<br>

<?php
// Use $HTTP_SESSION_VARS with PHP 4.0.6 or less
if (!isset($_SESSION['playerid'])) {
?>


<a href="index.php?page=home">Home</a><br>
<a href="index.php?page=progress">Progress</a><br>
<a href="index.php?page=encyclopedia">Encyclopedia</a><br>
<a href="index.php?page=support">Support</a><br>
<a href="http://www.crikeygames.com.au/forum/">Forum</a><br><br>

<?php
// Use $HTTP_SESSION_VARS with PHP 4.0.6 or less
}
if (isset($_SESSION['playerid'])) {
?>

<a href="index.php?page=base">Base</a><br>
<a href="index.php?page=inventory">Inventory</a><br>
<a href="index.php?page=encyclopedia">Encyclopedia</a><br>
<a href="index.php?page=support">Support</a><br>
<a href="index.php?page=logout">Logout</a><br><br>

<hr>
Ammo: <?php echo $player_ammo; ?><br>
Money: <?php echo $player_money; ?><br>
Bank: <?php echo $player_bank; ?><br>
Health: <?php echo $player_currenthealth; ?>/<?php echo $player_maxhealth; ?><br>
Power: <?php echo $player_currentpower; ?>/<?php echo $player_maxpower; ?>
<hr>

<?php } ?>





</div>

Morning Everyone,

 

When I added the if statement to leftnav(the one you said) I get this error now:

Fatal error: Call to undefined function: player_table() in /home/ace/public_html/conflictingforces/leftnav.php on line 17

 

and its just showing the background image, and header again.

I've found where the loop was! How ever fixing it has created another error. But this one isnt as serious.

The whole page is loading now, leftnav, rightnav, header, footer, and center. But their is this error right after the header.

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 8 in /home/ace/public_html/conflictingforces/functions.php on line 33

 

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 9 in /home/ace/public_html/conflictingforces/functions.php on line 33

 

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 10 in /home/ace/public_html/conflictingforces/functions.php on line 33

 

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 11 in /home/ace/public_html/conflictingforces/functions.php on line 33

 

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 12 in /home/ace/public_html/conflictingforces/functions.php on line 33

 

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 13 in /home/ace/public_html/conflictingforces/functions.php on line 33

 

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 14 in /home/ace/public_html/conflictingforces/functions.php on line 33

 

Heres what my current functions.php page is(with the loop fixed):

<?php // conflicting forces functions

// Put this at the top of pages you need to be logged into
function player_session() {

// Check whether the player id variable has been set, if it hasn't, log them out
if (!isset($_SESSION['playerid'])) {

// Destroy the session
session_destroy();

// Automatically redirect to the homepage
//header("Location: index.php?page=home");
die("Failed: <a href='index.php?page=home'>Home</a>");
}	

};


// Select fields from the user table
function player_table($select) {

$where = $_SESSION['playerid'];

$rs = mysql_connect( "localhost", "ace_ACE", "*****" );
$rs = mysql_select_db( "ace_cf" );

// SQL query for all entries in descending order
$sql = "SELECT `" . $select . "` FROM `cf_users` WHERE `id`='" . $where . "' LIMIT 1";
$rs = mysql_query( $sql ) or die('Query:<br />' . $sql . '<br /><br />Error:<br />' . mysql_error());

// This gets the data from the result resource
$query = mysql_result($rs,0,0);

return $query;


};

?>

 

Now I just gotta figure out whats causing this MySQL error, the error message points to:

// This gets the data from the result resource
$query = mysql_result($rs,0,0);

 

But it was working fine before, so whats wrong with it now?

I've fixed the MySQL error, Now when I login and get to base.php I am getting this error:

Fatal error: Cannot redeclare player_session() (previously declared in /home/ace/public_html/conflictingforces/functions.php:7) in /home/ace/public_html/conflictingforces/functions.php on line 4
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.