Altec Posted October 25, 2008 Share Posted October 25, 2008 Hey, after finishing a few more blocks of my code I tried to run it; I'm getting an unexpected T_CASE error on line 112. If you could take a look and help me figure this out that would be great; I don't see anything amiss. <?php // Change display_errors to 0 ini_set('display_errors', 0); // Include the database, strings, and template engine files require_once('includes/database.php'); require_once('includes/strings.php'); require_once('includes/templatesys.php'); // Connect to the database if(!mysql_connect(DB_SERVER, DB_USER, DB_PASS)) { $page = new Page('templates/sys/info.html'); $page->replace_tags(array( 'CONTENT' => $string['DATABASE_CONNECT_ERROR'] . ' - ' . mysql_error(), 'REFRESH' => '', )); $page->output(); exit; } // Select the database if(!mysql_select_db('phreakyo_sandbox')) { $page = new Page('templates/sys/info.html'); $page->replace_tags(array( 'CONTENT' => $string['DATABASE_SELECT_ERROR'] . ' - ' . mysql_error(), 'REFRESH' => '', )); $page->output(); exit; } // Switch function will "switch" between blocks of code based // on the value of $_GET['action']. switch($_GET['action']) { case 'post': // Check if a post was submitted; if not, display form if(!isset($_POST['submit'])) { $page = new Page('templates/index.html'); $page->replace_tags(array( 'PAGE_TITLE' => 'Post New Entry', 'MENU' => 'templates/menu.html', 'TITLE' => 'Post New Entry', 'CONTENT' => 'templates/sys/new_post.php', 'SIDEBAR' => 'templates/sidebar.html', 'FOOTER' => 'templates/footer.html', )); $page->output(); } // Otherwise enter the post into the database elseif(isset($_POST['submit'])) { $fields = array( 'month' => $_POST['month'], 'date' => $_POST['date'], 'year' => $_POST['year'], 'time' => $_POST['time'], 'title' => $_POST['title'], ); foreach($fields as $key => $value) { $value = trim($value); if(empty($value)) { $error .= 'Field ' . $key . ' empty.<br />'; } $fields[$key] = htmlspecialchar(strip_tags($value)); } if(isset($error)) { $page = new Page('templates/sys/info.html'); $page->replace_tags(array( 'CONTENT' => $string['POST_FIELD_EMPTY'] . '<br /><br />' . $error, 'REFRESH' => '', )); $page->output(); exit; } extract($fields); $entry = $_POST['entry']; $timestamp = strtotime($month . " " . $date . " " . $year . " " . $time); $entry = nl2br($entry); if(!get_magic_quotes_gpc()) { $title = mysql_real_escape_string($title); $entry = mysql_real_escape_string($entry); } $query = "INSERT INTO posts (timestamp,title,entry) VALUES ('$timestamp','$title','$entry')"; if(!mysql_query($query)) { $page = new Page('templates/sys/info.html'); $page->replace_tags(array( 'CONTENT' => $string['POST_INSERT_ERROR'] . ' - ' . mysql_error(), 'REFRESH' => '', )); $page->output(); } else { $page = new Page('templates/sys/info.html'); $page->replace_tags(array( 'CONTENT' => $string['POST_INSERT_SUCCESS'], 'REFRESH' => 'templates/sys/redirect.html', )); $page->output(); } } } break; case 'category': // Check if we submitted a new category if(isset($_POST['sub_new_cat'])) { $cat_name = trim(htmlspecialchar(strip_tags($_POST['new_cat']))); if(empty($cat_name)) { $page = new Page('templates/sys/info.html'); $page->replace_tags(array( 'CONTENT' => $string['CAT_SUB_ERROR'], 'REFRESH' => '', )); $page->output(); exit; } if(!get_magic_quotes_gpc()) { $cat_name = mysql_real_escape_string($cat_name); } $query = "INSERT INTO categories (name) VALUES ('$cat_name')"; if(!mysql_query($query)) { $page = new Page('templates/sys/info.html'); $page->replace_tags(array( 'CONTENT' => $string['CAT_INSERT_ERROR'] . ' - ' . mysql_error(), 'REFRESH' => '', )); $page->output(); } else { $page = new Page('templates/sys/info.html'); $page->replace_tags(array( 'CONTENT' => $string['CAT_INSERT_SUCCESS'], 'REFRESH' => 'templates/sys/redirect.html', )); $page->output(); } } // Check if we want to edit a category elseif(isset($_POST['edit_cat'])) { } // Check if we want to delete a category elseif(isset($_POST['del_cat'])) { } // Otherwise we just came here else { $query = "SELECT * FROM categories"; if(!mysql_query($query)) { $page = new Page('templates/sys/info.html'); $page->replace_tags(array( 'CONTENT' => $string['CAT_DISPLAY_ERROR'] . ' - ' . mysql_error(), 'REFRESH' => '', )); $page->output(); exit; } // List our categories $page = new Page('templates/index.html'); $page->replace_tags(array( 'PAGE_TITLE' => 'Category List', 'MENU' => 'templates/menu.html', 'TITLE' => 'Category List', 'CONTENT' => 'templates/sys/cat_list.php', 'SIDEBAR' => 'templates/sidebar.html', 'FOOTER' => 'templates/footer.html', )); $page->output(); } break; default: $page = new Page('templates/sys/info.html'); $page->replace_tags(array( 'CONTENT' => $string['NO_ACTION'], 'REFRESH' => '', )); $page->output(); break; } // Close the MySQL connection link mysql_close(); ?> I know it is a bit long; line 112 reads " case 'category': " Link to comment https://forums.phpfreaks.com/topic/130090-solved-unexpected-t_case/ Share on other sites More sharing options...
Altec Posted October 25, 2008 Author Share Posted October 25, 2008 Had an extra bracket in there. Link to comment https://forums.phpfreaks.com/topic/130090-solved-unexpected-t_case/#findComment-674500 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.