Jump to content

[SOLVED] Script Just stopped working, with no errors


elite_prodigy

Recommended Posts

I don't even know what is going on here, but there are several files involved, and I'll post them all here.

 

Basically, $page->content is not outputting the links to edit each page, and when I type the URL directly that would take me to the page that edits that page, I get a blank screen.

 

When I echo $page->content from within the file that sets it, it works fine, but when I try to echo it from index.php, it echos nothing.

 

The only exception here is in editPage.php, if there is more than one record in the database, I get the second record and not the first.

 

Now, I know the right files are being included and that they are actually retrieving the right information because when I echo directly from the file that sets $page->content, I see exactly what I am supposed to, but at the top of the page.

 

Thanks everyone, you people are amazing, I have spent the past three days moving this stuff around, trying to fix it, but to no avail. This is my last resort, you guys have saved me in the past, here's hoping it can happen again.

 

 


This is the index.php file, somewhere in the body, you will see <?php echo $page->content; ?> that's what's not working.

 

<?php

include 'php/main.php';

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<html>

<head>
<title>Site Control Pannel</title>
<LINK REL=StyleSheet HREF="overall.css" TYPE="text/css" MEDIA=screen>
</head>

<body>
<?php $page->tabs(); ?>

<div class="main">

<div class="nav">
	<br /><br />

	<?php echo $page->nav; ?>

</div>

<div class="divide">



</div>

<div class="disp">
	<br /><br />

	<?php echo $page->content; ?>

</div>

</div>
          
</body>

</html>

 


This is the classes.php file, which has all of the classes declared inside.

<?php

include 'config.php';

class Page{

function Page(){

	if(isset($_GET['id'])){

		$this->id			= $_GET['id'];

	}
	else{

		$this->id			= 0;

	}

	if(isset($_GET['option'])){

		$this->option		= $_GET['option'];

	}
	else{

		$this->option		= 0;

	}

	//pre-initialize append-only variables
	$this->tab_list		= "";
	$this->options		= "";

}

function tabs(){ //generates the tabs at the top of the box

	$tab_name				= array('Pages',
									'Staff',
									'Profile',
									);

	$tab_loc				= array('index.php?id=0&option=0',
									'index.php?id=1&option=0',
									'index.php?id=2&option=0',
									);

	for($size = 0; $size < count($tab_loc); $size++){

		if($this->id == $size){

			$this->tab_list		.= '<div class="visit_tab_outer">
										<div class="visit_tab_inner">
											<a href="'.$tab_loc[$size].'">'.$tab_name[$size].'</a>
										</div>
									</div>';
			continue;

		}

		$this->tab_list		.= '<div class="tab_outer">
								<div class="tab_inner">
									<a href="'.$tab_loc[$size].'">'.$tab_name[$size].'</a>
								</div>
							</div>';

	}

	echo $this->tab_list;

}

function appendOp($path, $name, $params = ""){ //adds an option to the sidebar of the page

	if(!empty($params)){

		$path				.= "?";

	}

	$this->nav			.= '<a href="'.$path.$params.'">'.$name.'</a>';

}

function setContent($content){ //set the content of the main body of the page

	$this->content		= $content;

}

}

?>

 


 

This is the main.php file included in index.php.

 

<?php

include 'classes.php';

$page			= new Page;

switch($page->id){

case 0:{

	include 'pageOptions.php';

	break;

}

case 1:{

	include 'staffOptions.php';

	break;

}

case 2:{

	include 'profileOptions.php';

	break;

}

}

?>

 


 

This is the pageOptions.php file included in main.php

 

<?php

include 'classes.php';

$page			= new Page;

switch($page->id){

case 0:{

	include 'pageOptions.php';

	break;

}

case 1:{

	include 'staffOptions.php';

	break;

}

case 2:{

	include 'profileOptions.php';

	break;

}

}

?>

 


 

This is the editPage.php file included in pageOptions.php

 

<?php

include 'config.php';

mysql_select_db("exembar_site");

$query 				= "SELECT * FROM `navigation`";

$result 			= mysql_query($query);

$body 				= "";

while($pages = mysql_fetch_array($result)){

$disp 				= $pages['display'];
$id 				= $pages['id'];

$body 				.= '<a href="'.$root.'index.php?id=0&option=1&page='.$id.'">'.$disp.'</a>';

}

$page->setContent($body); //if I could kick this, I would
echo $page->content; //this works, but it echoed above my page, and looks awful

?>

 


 

This is frmEditPage.php included in pageOptions.php

 

<?php

include 'config.php';
mysql_select_db("exembar_site");

$query 			= "SELECT * FROM `navigation` WHERE `id`=".$_GET['page'];
$result 		= mysql_query($query);
$info 			= mysql_fetch_array($result);
$navbar			= $info['display'];

$query 			= "SELECT * FROM `pages` WHERE `navId`=".$_GET['page'];
$result 		= mysql_query($query);
$info 			= mysql_fetch_array($result);
$title 			= $info['title'];

$query 			= "SELECT * FROM `pgContent` WHERE `navId`=".$_GET['page'];
$result 		= mysql_query($query);
$info 			= mysql_fetch_array($result);
$top 			= $info['topBar'];
$content		= $info['content'];

$body 			='

			<form name="create" method="post" action="php/doEditPage.php?id='.$_GET['page'].'">
			<div class="label">Page Title:</div> <input type="text" name="title" class="field" value="'.$title.'"/> 
			<div class="label">Nav Text:</div> <input type="text" name="display" class="field" value="'.$navbar.'"/> 
			<div class="label">Top Bar:</div> <input type="text" name="topbar" class="field" value="'.$top.'"/> 
			<div class="label">Content: tags: [<br /> <a> <img> <i> <b> <u>]</div>
			<textarea rows="15" cols="52" name="content" class="lgfield">'.$content.'</textarea> <br />
			<input type="submit" value="Edit"  class="button"/>
			</form>

		';

$page->setContent($body);
echo $page->content;

?>

Link to comment
Share on other sites

You should be getting errors. Your including the same files multiple times which meens classes are being defined more than once. Turn error reporting to E_ALL and set display errors to on when developing.

 

error_reporting(E_ALL) ; ini_set('display_errors', 1);

Link to comment
Share on other sites

Okay, I accidentally pasted main.php where pageOptions.php should be.

 

The REAL pageOptions.php

 

<?php
error_reporting(E_ALL);

$page->appendOp("index.php", "Add a Page", "id=0&option=0");
$page->appendOp("index.php", "Edit a Page", "id=0&option=1");
$page->appendOp("index.php", "Delete a Page", "id=0&option=2");

switch($page->option){

case 0:{

	include 'addPage.php';

	break;

}

case 1:{

	if(isset($_GET['page'])){

		include 'frmEditPage.php';

	}
	else{

		include 'editPage.php';

	}

}

case 2:{

	include 'deletePage.php';

}

}

?>

Link to comment
Share on other sites

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.