elite_prodigy Posted January 12, 2009 Share Posted January 12, 2009 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 https://forums.phpfreaks.com/topic/140479-solved-script-just-stopped-working-with-no-errors/ Share on other sites More sharing options...
trq Posted January 12, 2009 Share Posted January 12, 2009 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 https://forums.phpfreaks.com/topic/140479-solved-script-just-stopped-working-with-no-errors/#findComment-735138 Share on other sites More sharing options...
trq Posted January 12, 2009 Share Posted January 12, 2009 ps: You should really look at using a UNION within a single query instead of running multiple queries like that also. Its terribly inefficient. Link to comment https://forums.phpfreaks.com/topic/140479-solved-script-just-stopped-working-with-no-errors/#findComment-735140 Share on other sites More sharing options...
elite_prodigy Posted January 12, 2009 Author Share Posted January 12, 2009 What files are being included more than once? classes.php is only included in main.php EDIT: I've added error_reporting(E_ALL); to every single file, and absolutely no error is being reported. Link to comment https://forums.phpfreaks.com/topic/140479-solved-script-just-stopped-working-with-no-errors/#findComment-735144 Share on other sites More sharing options...
trq Posted January 12, 2009 Share Posted January 12, 2009 Both main.php and pageOptions.php include classes.php. Did you turn error reporting on? Link to comment https://forums.phpfreaks.com/topic/140479-solved-script-just-stopped-working-with-no-errors/#findComment-735146 Share on other sites More sharing options...
elite_prodigy Posted January 12, 2009 Author Share Posted January 12, 2009 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 https://forums.phpfreaks.com/topic/140479-solved-script-just-stopped-working-with-no-errors/#findComment-735147 Share on other sites More sharing options...
trq Posted January 12, 2009 Share Posted January 12, 2009 Is display errors on? Its pretty hard from here to tell what is included where, I'm sure that is where your issue lies. Link to comment https://forums.phpfreaks.com/topic/140479-solved-script-just-stopped-working-with-no-errors/#findComment-735149 Share on other sites More sharing options...
elite_prodigy Posted January 12, 2009 Author Share Posted January 12, 2009 I've added error_reporting(E_ALL); to the top of all of the files. Is there some other way to force errors out of PHP that I should know about? Link to comment https://forums.phpfreaks.com/topic/140479-solved-script-just-stopped-working-with-no-errors/#findComment-735150 Share on other sites More sharing options...
trq Posted January 12, 2009 Share Posted January 12, 2009 error_reporting(E_ALL) ; ini_set('display_errors', 1); Link to comment https://forums.phpfreaks.com/topic/140479-solved-script-just-stopped-working-with-no-errors/#findComment-735151 Share on other sites More sharing options...
elite_prodigy Posted January 12, 2009 Author Share Posted January 12, 2009 I went through and added ini_set('display_errors', 1); error_reporting(E_ALL); to the top of every file, then I went through again and replaced the above with error_reporting(E_ALL); ini_set('display_errors', 1); and still no errors. Link to comment https://forums.phpfreaks.com/topic/140479-solved-script-just-stopped-working-with-no-errors/#findComment-735163 Share on other sites More sharing options...
elite_prodigy Posted January 12, 2009 Author Share Posted January 12, 2009 Does anyone know why this is happening, and not producing errors? Link to comment https://forums.phpfreaks.com/topic/140479-solved-script-just-stopped-working-with-no-errors/#findComment-735231 Share on other sites More sharing options...
elite_prodigy Posted January 12, 2009 Author Share Posted January 12, 2009 I can't believe no one caught this, and I'm not sure at which point I figured it out, nor why I didn't notice it sooner, but I was missing break;s in my pageOptions.php file. Thanks for all the input though. -David Link to comment https://forums.phpfreaks.com/topic/140479-solved-script-just-stopped-working-with-no-errors/#findComment-735395 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.