CK9 Posted May 24, 2012 Share Posted May 24, 2012 Hello, I've been playing around with a coding experiment that I did previously. I've been teaching myself javascript and css to take some of the load off the server side of things, but in changing my code, I've come to a new error: Fatal error: Cannot redeclare tablestart() (previously declared in /home/ck9/public_html/planning/forumbuild/list.php:10) in /home/ck9/public_html/planning/forumbuild/list.php on line 13 The first thing I did was search for the error. I don't have the function declared more than once, and include_once() did not fix the issue. Here is what I have: list.php which has not changed and worked fine prior to making the changes: <?php include("db.class.php"); include("db.config.php"); $db = new databaseConnection($config['user'],$config['pass'],$config['database']); $g = $_GET['g']; $s = $_GET['s']; $t = $_GET['t']; function tablestart($a = '1') { echo "<table border='" . $a . "' cellpadding='10' cellspacing='0' align='center' width='80%' style='color: #C0C0C0'>\n"; } function contents($db, $table, $a, $b = '1', $c = '1') { $db->query("SELECT * FROM $table"); while($row = $db->fetch_array()) { if($row['level'] <= $_SESSION['ulevel']) { echo "<tr><td width='5%'><!--indicator--></td><td width='80%'><a href='index.php?pg=h&g='" . $row['g']; if(($a > '1') && ($row['g'] == $b)) { echo "&s=" . $row['s']; if(($a > '2') && ($row['s'] == $c)) { echo "&t=" . $row['t']; } } } echo "' style='color: #C0C0C0 ; text-decoration: none'><font size='4'>" . $row['name'] . "</font><br /><fpnt size='3'>" . $row['desc'] . "</td><td width='15%'><!--last update--></td></tr>\n"; } } if(empty($_SESSION['ulevel'])) { $_SESSION['ulevel'] = '0'; echo "<font color='#CC0000'><center>You need to register to post in these forums.</center></font><br />\n"; } if(empty($g)) { tablestart(); contents($db, 'fgroup', '1'); echo "</table>\n"; } elseif(empty($s)) { tablestart(); contents($db, 'section', '2', $g); echo "</table>\n"; } elseif(empty($t)) { tablestart('0'); echo "<tr><td width='80%'></td><td><!--new topic--></td></tr>\n</table>\n"; tablestart(); contents($db, 'topic', '3', $g, $s); echo "</table>\n"; } elseif(!empty($t)) { tablestart('0'); echo "<tr><td width='80%'></td><td><!--new topic and reply--></td></tr>\n</table>\n"; $data = file_get_contents('post.txt'); $post = explode("<!--p-->", $data); $length = count($post); tablestart('1'); for($z = '0'; $z < $length; $z ++) { $i = '0'; $cont = explode("<!--e-->", $post[$pos]); echo "<tr><td><b>" . $cont[$i] . "</b><br /><!--future additions--></td><td>\n<table width='100%' style='font-size: xx-small'>\n<tr><td height='3' width='75%'>"; $i ++; echo "Posted on" . $cont[$i] . "</td><td height='3' width='25%'><!--future additions--></td></tr><tr><td width='100%'>"; $i ++; echo $cont[$i] . "</td></tr></table></td></tr>\n"; } echo "</table>\n"; } ?> index.php with the original code set within an extended comment: <?php session_start(); if(empty($_GET['pg'])) { $pg = 'h'; } else { $pg = $_GET['pg']; } switch($pg) { case 'h': $a = 'home'; $b = 'tlsection-h'; include_once('list.php'); break; case 'p': $a = 'posting'; $b = 'tlsection-p'; include('post.php'); break; case 'l': $a = 'logging'; $b = 'tlsection-l'; include('log.php'); break; case 'v': $a = 'verification'; $b = 'tlsection-v'; include('verify.php'); break; case 'm': $a = 'members'; $b = 'tlsection-m'; include('mem.php'); break; } ?> <html> <head> <!-- meta tags to go here --> <?php echo " <title>Omega Command - Forum - " . $a . "</title>\n"; ?> <!-- Special thanks to TH300 for letting me look through his css coding to learn from it --> <link rel='stylesheet' type='text/css' href='style.css' /> </head> <body> <div class='PageBody'> <?php echo " <div class='" . $b . "'>\n"; ?> <div class='HeaderSection'> <div class='HeaderBanner'> <img src='elements/headbar2.png' alt='Yup, it's a forum'> </div> <div class='NavBar'> <?php require_once('navigation.php'); ?> </div> </div> <!-- end header --> <div class='MainSection'> <div class='NavMenu'> <!-- need to figgure out what goes here --> </div> <!-- end nav menu --> <div class='contents'> <?php pageswitch($pg); ?> </div> <!-- end contents --> </div> <!-- end main section --> <div class='FooterSection'> <!-- optional footer image --> </div> <!-- end footer section --> </div> </div> </body> </html> /*<?php session_start(); ?> <body bgcolor='#000000'> <?php function pageswitch($pg) { include("header.php"); switch ($pg) { case 'h': include('list.php'); break; case 'p': include('post.php'); break; case 'l': include('log.php'); break; case 'v': include('verify.php'); break; case 'm': include('mem.php'); break; } include('footer.html'); } ?> <table width='100%' border='0' cellpadding='0' cellspacing='0' align='center'> <tr><td width='100%'><center><img src='elements/headbar.png'></center></td></tr> <tr><td width='100%' height='2' bgcolor='#C0C0C0'></td></tr><tr><td height ='10' width='100%'> <?php require('navigation.php'); ?> </td></tr> <tr><td width='100%' height='2' bgcolor='#C0C0C0'></td></tr> </table> <table width='100%' border='0' cellpadding='0' cellspacing='0' align='center'><tr> <?php if(empty($_GET['pg'])) { $page = 'h'; } else { $page = $_GET['pg']; } if($page == 'h' && !isset($_GET['g'])) { echo "<td width='24%'>"; include('sidebar.php'); echo "</td><td width='1' height='100%' bgcolor='#C0C0C0'></td><td width='75%'>"; } else { echo "<td width='100%'>"; } echo "<br />"; pageswitch($page); ?> <br /></td></tr></table> <table width='100%' border='0' cellpadding='0' cellspacing='0' align='center'> <tr><td width='100%' height='2' bgcolor='#C0C0C0'></td></tr> </table><br /> <center><font color='#C0C0C0' size='2'>This forum was coded by CK9 as an experiment with PHP. It is very basic and does not garuntee security. Refrain from storing sensitive information here.</center>*/ As you can see, on list.php line 10 is the function declaration and line 13 is the closing brace. From what I see, and the fact this page was working perfectly before the change, this error should not be happening... Is there something obvious I'm just not seeing? Quote Link to comment https://forums.phpfreaks.com/topic/263085-fatal-error-cannot-redefinefixes-found-not-working/ Share on other sites More sharing options...
Kays Posted May 24, 2012 Share Posted May 24, 2012 Yes, you're trying to include_once list.php twice. You had a /* (assuming you commented out), but you weren't in PHP mode and are in HTML mode. so that /* */ didn't really comment it out. You cannot comment out PHP from executing with <!-- HTML COMMENT --> so don't try it. Quote Link to comment https://forums.phpfreaks.com/topic/263085-fatal-error-cannot-redefinefixes-found-not-working/#findComment-1348446 Share on other sites More sharing options...
CK9 Posted May 24, 2012 Author Share Posted May 24, 2012 and I'm a dumbass >.< lol, thanks for pointing that out, been so long since I've done anything with php that I didn't even notice that, and you indirectly made me realize something else I missed (removed a function that I actually need to use for the contents to go in the correct location). Quote Link to comment https://forums.phpfreaks.com/topic/263085-fatal-error-cannot-redefinefixes-found-not-working/#findComment-1348459 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.