Jump to content
Larry Ullman's Book Forums

hartofboone

Members
  • Content Count

    11
  • Joined

  • Last visited

Community Reputation

0 Neutral

About hartofboone

  • Rank
    Newbie
  1. Hi Larry, Just want to say thanks for your help in the past. I wasn't really expecting the author to answer questions, lol! I have both the first and second site coded and working (well, except for SSL checkout issue in ex2). However I can't even get the first update in Chapter 12 to ex1 working! Our teacher assigned both chapters 12 and 13 this week for class and I don't see that happening with the problems I'm having getting through just the first part of chapter 12! I personally work better off seeing working code. Do you have a working page.php from chapter 5 (starting on page 130) and one from chapter 12 so I can see the differences? I also noticed the code in the book is different than the database sql and the actual page.php code, which I assume was an update or something? Book code: INSERT INTO history (user_id, type, item_id) VALUES ($user_id, ‘page’, $page_id) page.php code: INSERT INTO history (user_id, type, page_id) VALUES ({$_SESSION['user_id']}, 'page', $page_id) Here is my page.php: <?php // This page displays a specific page of HTML content. // This script is created in Chapter 5. // Require the configuration before any PHP code as the configuration controls error reporting: require('./includes/config.inc.php'); // The config file also starts the session. // Require the database connection: require(MYSQL); $_SESSION['user_id'] =12; $_SESSION['user_not_expired'] = true; // Validate the category ID: if (isset($_GET['id']) && filter_var($_GET['id'], FILTER_VALIDATE_INT, array('min_range' => 1))) { $page_id = $_GET['id']; // Get the page info: $q = 'SELECT title, description, content FROM pages WHERE id=' . $page_id; $r = mysqli_query($dbc, $q); if (mysqli_num_rows($r) !== 1) { // Problem! $page_title = 'Error!'; include('./includes/header.html'); echo '<div class="alert alert-danger">This page has been accessed in error.</div>'; include('./includes/footer.html'); exit(); } // Fetch the page info: $row = mysqli_fetch_array($r, MYSQLI_ASSOC); $page_title = $row['title']; include('includes/header.html'); echo '<h1>' . htmlspecialchars($page_title) . '</h1>'; // Display the content if the user's account is current: if (isset($_SESSION['user_not_expired'])) { $user_id = $_SESSION['user_id']; // Bonus material! Referenced in Chapter 12. // Create add to favorites and remove from favorites links: // See if this is favorite: $q = 'SELECT user_id FROM favorite_pages WHERE user_id=' . $user_id . ' AND page_id=' . $page_id; $r = mysqli_query($dbc, $q); if (mysqli_num_rows($r) === 1) { echo '<h3 id="favorite_h3"><img src="images/heart_32.png" width="32" height="32"> <span class="label label-info">This is a favorite!</span> <a id="remove_favorite_link" href="remove_from_favorites.php?id=' . $page_id . '"><img src="images/close_32.png" width="32" height="32"></a></h3>'; } else { echo '<h3 id="favorite_h3"><span class="label label-info">Make this a favorite!</span> <a id="add_favorite_link" href="add_to_favorites.php?id=' . $page_id . '"><img src="images/heart_32.png" width="32" height="32"></a></h3>'; } // Show the page content: echo "<div>{$row['content']}</div>"; // Bonus material! Referenced in Chapter 12. // Record this visit to the history table: $q = "INSERT INTO history (user_id, type, page_id) VALUES ({$_SESSION['user_id']}, 'page', $page_id)"; $r = mysqli_query($dbc, $q); // Bonus material! Referenced in Chapter 12. // Allow the user to take notes: // Check for a form submission: if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (isset($_POST['notes']) && !empty($_POST['notes'])) { $notes = $_POST['notes']; $q = "REPLACE INTO notes (user_id, page_id, note) VALUES ($user_id, $page_id, '" . escape_data($notes, $dbc) . "')"; $r = mysqli_query($dbc, $q); if (mysqli_affected_rows($dbc) > 0) { echo '<div class="alert alert-success">Your notes have been saved.</div>'; } } } // Get the existing notes, if any: if (!isset($notes)) { $q = "SELECT note FROM notes WHERE user_id=$user_id AND page_id=$page_id"; $r = mysqli_query($dbc, $q); if (mysqli_num_rows($r) === 1) { list($notes) = mysqli_fetch_array($r, MYSQLI_NUM); } } echo '<form id="notes_form" action="page.php?id=' . $page_id . '" method="post" accept-charset="utf-8"> <fieldset><legend>Your Notes</legend> <textarea name="notes" id="notes" class="form-control">'; if (isset($notes) && !empty($notes)) echo htmlspecialchars($notes); echo '</textarea><br> <input type="submit" name="submit_button" value="Save" id="submit_button" class="btn btn-default" /> </fieldset> </form>'; } elseif (isset($_SESSION['user_id'])) { // Logged in but not current. echo '<div class="alert"><h4>Expired Account</h4>Thank you for your interest in this content, but your account is no longer current. Please <a href="renew.php">renew your account</a> in order to view this page in its entirety.</div>'; echo '<div>' . htmlspecialchars($row['description']) . '</div>'; } else { // Not logged in. echo '<div class="alert">Thank you for your interest in this content. You must be logged in as a registered user to view this page in its entirety.</div>'; echo '<div>' . htmlspecialchars($row['description']) . '</div>'; } } else { // No valid ID. $page_title = 'Error!'; include('includes/header.html'); echo '<div class="alert alert-danger">This page has been accessed in error.</div>'; } // End of primary IF. // Add the JavaScript: // Added in Chapter 14. echo '<script type="text/javascript"> var page_id = ' . $page_id . '; </script> <script src="js/favorite.js"></script> <script src="js/notes.js"></script>'; // Include the HTML footer: include('./includes/footer.html'); ?>
  2. Chapter 11 sets up an admin interface to populate the database. The menus that return no products are working, just the database hasn't been populated yet is what i found out with my pages above. Speaking of Chapter 11: I pulled the admin subdirectory back up one directory leve so it is even with the html subdirectory. Got it coded up similar to the html subdirectory. The mysql.ini.php for example I only had to change html to admin in the BASE_URL to get stuff working. For some pages I did have to walk up one directory and down the html subdirectory to get to the .js or .css or images subdirectory but it was easy to figure out. define ('BASE_URI', 'c:/xampp/htdocs/jbhart/WEB260/ex2/'); define ('BASE_URL', 'localhost/jbhart/WEB260/ex2/admin/');
  3. Hi Larry, Pretty much got all my links working, got .htaccess and mod_rewrites on Apache working, got images loading, got css working but I was wondering why some data from the database is being returned while other data in the same table and page returns nothing. It's probably easier to just show the pages and see if you have any suggestions. Here is my Coffee page: If I select Dark Roast nothing is returned from the database and it loads the error page: If I choose Kona it appears to pull data from the database and work. Don't understand why one works and the other doesn't. Thanks for look at this!
  4. I'm running XAMPP on my pc and I foundout that the httpd.conf for Apache needs to be edited and have "AllowOverride none" changed to "AllowOverride All" for the mod_rewrite to work. Then test to see if your .htaccess is working. To do that add something like RewriteRule ^test.php index.php in the .htaccess file.
  5. Hi Larry, Yep, It's 1am and I'm still working on Chapter 7-9 of your book. In the book you said you don't need to use mod_rewrites and you would tell use how. I don't see how listed for anything other than the menu links: Chapter 8, page 232 As a reminder, the PHP script for listing the product categories is called shop.php, and it’s linked in the header as either /shop/coffee/ or /shop/goodies/. The server’s mod_rewrite module will convert that URL (unbeknownst to the user) into either shop.php?type=coffee or shop.php?type=goodies. If you’re not using mod_rewrite, then your URLs should just be those. Please I don't want to use mod_rewrites. I just want the site to work. I have the main page links working using this for the shopping links: <li><a href="/jbhart/WEB260/ex2/html/shop.php?type=coffee">Coffee</a></li> <li><a href="/jbhart/WEB260/ex2/html/shop.php?type=goodies">Goodies</a></li> <li><a href="/jbhart/WEB260/ex2/html/shop.php?type=sales">Sales</a></li> Now I'm trying to get all the little icons working on each page. On the coffee page for example what is the real URL for Dark Roast, Kona, and Original blend. What i have is the htaccess version which doesn't work and I have no idea how html is suppose to convert it to a real URL. Can you tell me what the real URL is for these links so I can figure out what to change? Since this is user output we are talking about and it MVC is the file for coffee in the view subdirectory? Is it list_coffees2.html? Trying to figure out how you are generating urls is really difficult. Thanks for any help! http://localhost/browse/coffee/Dark+Roast/2 http://localhost/browse/coffee/Kona/3 http://localhost/browse/coffee/Original+Blend/1 P.S. Don't know if it would help anyone else but if I had reviewed your book before publishing I would have suggest you make an alternate version that doesn't use .htaccess and mod_rewrites. Everyone in my class is going nuts trying to get your links and stuff to work much less figure out how to convert .htaccess to work on our IIS school server. Thanks.
  6. I fixed two errors with my add_pdf.php upload to MySQL database tonight! My environment is both localhost using XAMPP and a school Wake Tech server. First problem. I was getting an error message something about can initialize fileinfo(). Found out that the php.ini need the comment removed in front of the following line: extension=php_fileinfo.dll Restarted the apache server after the change and add_pdf.php works now. Second problem. On school server I was getting a different message. Big long error message that dropped to line 141 and said I had a system error. Error message was useless for debug. Read through the actual error and it said description was two long. Went into database and changed the size of the description field in the pdfs table from tinytext to just text. Ran the add_page.pdf and it ran clean. Hope this helps anyone with either of these errors!
  7. I had the same problem with the undefined function finfo_open() when I tried to upload a pdf. I'm running XAMPP. To fix it I edited the main php.ini. Remove the comment from the following extension and restart the apache server to enable the fileinfo extension extension=php_fileinfo.dll
  8. Yea! You nailed it on the first try. Thanks for spending time looking over my code! I've been taking classes at the community college for 4 years (part time) while working full time and this is the first class I've had problems with. Thanks for the fix!!!!!!! Category was trying to use array to pick up multiple categories and was dying. So, for anyone else here is what I did to go back to picking a single category and have the add_page.php work again: Comment out the following lines in add_page.php to stop category trying to use an array: echo '"><label for="category" class="control-label">Category</label> <select name="category[]" class="form-control" multiple size="5">'; Comment in the following line (right above it) to have category go back to a single select: echo '"><label for="category" class="control-label">Category</label> <select name="category" class="form-control"> <option>Select One</option>';
  9. Hi Larry! Sorry, no idea what the value for category is. I'm a student. I'm not running an ide where I can trace stuff like in C++, just a text editor. Not sure how to run a trace for string or array variables in PHP. I tried to echo and print out the value of category but since it's an array value I get a you can't print out a string value from an array. Looked here also: http://stackoverflow.com/questions/4383914/how-to-get-single-value-from-php-array but not sure if that would work or what to plug in. Any suggestion is helpful. As I said before if I remove the category validation stuff, and $cat, the page posts with a category id of 0 in the database (using phpMyAdmin to look), but it posts a row! Not sure how the add_page.php select pulldown to select a category is suppose to interact with the table with the categories or pages tables. Not explained in the book. The database categories table lists the 5 categories and their related ids. Thanks, Joe I've been playing with the add_page.php code. Here is what I currently have: <?php // This page is used by an administrator to create a specific page of HTML content. // This script is created in Chapter 5. // Require the configuration before any PHP code as the configuration controls error reporting: require('./includes/config.inc.php'); // If the user isn't logged in as an administrator, redirect them: redirect_invalid_user('user_admin'); // Require the database connection: require(MYSQL); // Include the header file: $page_title = 'Add a Site Content Page'; include('./includes/header.html'); // For storing errors: $add_page_errors = array(); // Check for a form submission: if ($_SERVER['REQUEST_METHOD'] === 'POST') { // Check for a title: if (!empty($_POST['title'])) { $t = escape_data(strip_tags($_POST['title']), $dbc); } else { $add_page_errors['title'] = 'Please enter the title!'; } /* // rem the lines below to get rid of category error. // Check for a category: if (filter_var($_POST['category'], FILTER_VALIDATE_INT, array('min_range' => 1))) { $cat = $_POST['category']; } else { // No category selected. $add_page_errors['category'] = 'Please select a category!'; } */ // Check for a category (Ch 5 Pg 118): if (filter_var($_POST['category'], FILTER_VALIDATE_INT, array('min_range' => 1))) { $cat = $_POST['category']; } else { // No category selected. $add_page_errors['category'] = 'Please select a category!'; } /* if (filter_var($_GET['category'], FILTER_VALIDATE_INT, array('min_range' => 1))) { $cat = $_GET['category']; } else { // No category selected. $add_page_errors['category'] = 'Please select a category!'; } */ /* Testing!!!! if (isset($_POST["category"])) { $user = $_POST["category"]; echo $user; echo " is your field name category"; } else { $user = null; echo "no field exists for category"; } */ // Check for a description: if (!empty($_POST['description'])) { $d = escape_data(strip_tags($_POST['description']), $dbc); } else { $add_page_errors['description'] = 'Please enter the description!'; } // Check for the content: if (!empty($_POST['content'])) { $allowed = '<div><p><span><br><a><img><h1><h2><h3><h4><ul><ol><li><blockquote>'; $c = escape_data(strip_tags($_POST['content'], $allowed), $dbc); } else { $add_page_errors['content'] = 'Please enter the content!'; } if (empty($add_page_errors)) { // If everything's OK. // Add the page to the database: $q = "INSERT INTO pages (category, title, description, content) VALUES ($cat, '$t', '$d', '$c')"; // TEST WITH NO CATEGORIES_ID - WORKS // $q = "INSERT INTO pages (title, description, content) VALUES ('$t', '$d', '$c')"; $r = mysqli_query($dbc, $q); if (mysqli_affected_rows($dbc) === 1) { // If it ran OK. // Print a message: echo '<div class="alert alert-success"><h3>The page has been added!</h3></div>'; // Clear $_POST: $_POST = array(); // Send an email to the administrator to let them know new content was added? } else { // If it did not run OK. trigger_error('The page could not be added due to a system error. We apologize for any inconvenience.'); } } // End of $add_page_errors IF. } // End of the main form submission conditional. // Need the form functions script, which defines create_form_input(): require('includes/form_functions.inc.php'); ?> <h1>Add a Site Content Page</h1> <form action="add_page.php" method="post" accept-charset="utf-8"> <fieldset><legend>Fill out the form to add a page of content:</legend> <div class="form-group"> <label for="status" class="control-label">Status</label> <select name="status" class="form-control"><option value="draft">Draft</option> <option value="live">Live</option> </select></div> <?php create_form_input('title', 'text', 'Title', $add_page_errors); // Add the category drop down menu: echo '<div class="form-group'; if (array_key_exists('category', $add_page_errors)) echo ' has-error'; /* echo '"><label for="category" class="control-label">Category</label> <select name="category" class="form-control"> <option>Select One</option>'; */ // Bonus material! // Added in Chapter 12. // Allow for multiple categories: echo '"><label for="category" class="control-label">Category</label> <select name="category[]" class="form-control" multiple size="5">'; // Retrieve all the categories and add to the pull-down menu: // $q = "SELECT id, category FROM categories ORDER BY category ASC"; // Sort the pull-down menu by id number NOT alphabetically by category $q = "SELECT id, category FROM categories ORDER BY id ASC"; $r = mysqli_query($dbc, $q); while ($row = mysqli_fetch_array($r, MYSQLI_NUM)) { echo "<option value=\"$row[0]\""; // Check for stickyness: if (isset($_POST['category']) && ($_POST['category'] == $row[0]) ) echo ' selected="selected"'; echo ">$row[1]</option>\n"; } echo '</select>'; if (array_key_exists('category', $add_page_errors)) echo '<span class="help-block">' . $add_page_errors['category'] . '</span>'; echo '</div>'; create_form_input('description', 'textarea', 'Description', $add_page_errors); create_form_input('content', 'textarea', 'Content', $add_page_errors); ?> <input type="submit" name="submit_button" value="Add This Page" id="submit_button" class="btn btn-default" /> </fieldset> </form> <script type="text/javascript" src="js/tinymce/tinymce.min.js"></script> <script type="text/javascript"> tinyMCE.init({ // General options selector : "#content", width : 800, height : 400, browser_spellcheck : true, plugins: "paste,searchreplace,fullscreen,hr,link,anchor,image,charmap,media,autoresize,autosave,contextmenu,wordcount", toolbar1: "cut,copy,paste,|,undo,redo,removeformat,|hr,|,link,unlink,anchor,image,|,charmap,media,|,search,replace,|,fullscreen", toolbar2: "bold,italic,underline,strikethrough,|,alignleft,aligncenter,alignright,alignjustify,|,formatselect,|,bullist,numlist,|,outdent,indent,blockquote,", // Example content CSS (should be your site CSS) content_css : "/ex1/html/css/bootstrap.min.css", }); </script> <!-- /TinyMCE --> <?php /* PAGE CONTENT ENDS HERE! */ // Include the footer file to complete the template: include('./includes/footer.html'); ?> Here is a dump of my sql.sql table. I've been messing with the categories and pages tables so the index and colums for categories, categories_id, category, are probably a little different than the book. -- phpMyAdmin SQL Dump -- version 4.2.7.1 -- http://www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Generation Time: Feb 14, 2017 at 06:09 AM -- Server version: 5.6.20 -- PHP Version: 5.5.15 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Database: `web260hart` -- -- -------------------------------------------------------- -- -- Table structure for table `categories` -- CREATE TABLE IF NOT EXISTS `categories` ( `id` smallint(6) NOT NULL, `category` varchar(30) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ; -- -- Dumping data for table `categories` -- INSERT INTO `categories` (`id`, `category`) VALUES (1, 'General Web Security'), (2, 'PHP Security'), (3, 'Common Attacks'), (4, 'JavaScript Security'), (5, 'Database Security'); -- -------------------------------------------------------- -- -- Table structure for table `favorite_pages` -- CREATE TABLE IF NOT EXISTS `favorite_pages` ( `user_id` int(10) unsigned NOT NULL, `page_id` mediumint(8) unsigned NOT NULL, `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Table structure for table `history` -- CREATE TABLE IF NOT EXISTS `history` ( `id` int(10) unsigned NOT NULL, `user_id` int(10) unsigned NOT NULL, `type` enum('page','pdf') DEFAULT NULL, `page_id` mediumint(8) unsigned DEFAULT NULL, `pdf_id` smallint(5) unsigned DEFAULT NULL, `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `notes` -- CREATE TABLE IF NOT EXISTS `notes` ( `id` int(10) unsigned NOT NULL, `user_id` int(10) unsigned NOT NULL, `page_id` mediumint(8) unsigned NOT NULL, `note` tinytext NOT NULL, `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `orders` -- CREATE TABLE IF NOT EXISTS `orders` ( `id` int(10) unsigned NOT NULL, `user_id` int(10) unsigned DEFAULT NULL, `transaction_id` varchar(19) NOT NULL, `payment_status` varchar(15) NOT NULL, `payment_amount` decimal(6,2) unsigned NOT NULL, `payment_date_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `pages` -- CREATE TABLE IF NOT EXISTS `pages` ( `id` mediumint(8) unsigned NOT NULL, `category` smallint(5) unsigned NOT NULL, `title` varchar(100) NOT NULL, `description` tinytext NOT NULL, `content` longtext NOT NULL, `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=22 ; -- -- Dumping data for table `pages` -- INSERT INTO `pages` (`id`, `category`, `title`, `description`, `content`, `date_created`) VALUES (1, 3, 'This is a Common Attack Article.', 'This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. ', '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>\r\n\r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit.\r\nAliquam tincidunt mauris eu risus.\r\nVestibulum auctor dapibus neque.\r\nNunc dignissim risus id metus.\r\nCras ornare tristique elit.\r\nVivamus vestibulum nulla nec ante.\r\n\r\n<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>', '2010-08-04 14:16:36'), (2, 5, 'This is a Database Security Article', 'This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. ', '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>\r\n<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>', '2010-08-04 14:17:28'), (3, 1, 'This is a General Web Security Article.', 'This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. ', '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>\r\n<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>', '2010-08-04 14:17:28'), (4, 4, 'This is a JavaScript Security Article.', 'This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. ', '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>\r\n<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>', '2010-08-04 14:17:28'), (5, 2, 'This is a PHP Security Article.', 'This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. ', '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>\r\n<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>', '2010-08-04 14:17:28'), (21, 0, 'ttt', 'desc', '<p>cccc</p>', '2017-02-14 04:51:49'), (20, 0, 'title', 'desc', '<p>content</p>', '2017-02-14 04:34:00'), (19, 0, 'ttt', 'desc', '<p>cccc</p>', '2017-02-13 02:05:57'); -- -------------------------------------------------------- -- -- Table structure for table `page_ratings` -- CREATE TABLE IF NOT EXISTS `page_ratings` ( `user_id` int(10) unsigned NOT NULL, `page_id` mediumint(8) unsigned NOT NULL, `rating` tinyint(3) unsigned NOT NULL, `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Table structure for table `pdfs` -- CREATE TABLE IF NOT EXISTS `pdfs` ( `id` smallint(5) unsigned NOT NULL, `tmp_name` char(40) NOT NULL, `title` varchar(100) NOT NULL, `description` tinytext NOT NULL, `file_name` varchar(40) NOT NULL, `size` mediumint(8) unsigned NOT NULL, `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE IF NOT EXISTS `users` ( `id` int(10) unsigned NOT NULL, `type` enum('member','admin') NOT NULL, `username` varchar(30) NOT NULL, `email` varchar(80) NOT NULL, `pass` varchar(255) DEFAULT NULL, `first_name` varchar(20) NOT NULL, `last_name` varchar(40) NOT NULL, `date_expires` date NOT NULL, `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `date_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; -- -- Dumping data for table `users` -- INSERT INTO `users` (`id`, `type`, `username`, `email`, `pass`, `first_name`, `last_name`, `date_expires`, `date_created`, `date_modified`) VALUES (1, 'admin', 'jbhartjr', 'jbhartjr@my.waketech.edu', '$2y$10$gN55yigJ/WnW9Iq4cxxOeuZ3yLLAhhD0vQ851E03LiVtBQQappqDy', 'Joe', 'Hart', '2017-02-05', '2017-02-07 04:20:33', '0000-00-00 00:00:00'); -- -- Indexes for dumped tables -- -- -- Indexes for table `categories` -- ALTER TABLE `categories` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `category` (`category`); -- -- Indexes for table `favorite_pages` -- ALTER TABLE `favorite_pages` ADD PRIMARY KEY (`user_id`,`page_id`); -- -- Indexes for table `history` -- ALTER TABLE `history` ADD PRIMARY KEY (`id`), ADD KEY `page_id` (`page_id`,`type`), ADD KEY `pdf_id` (`pdf_id`,`type`); -- -- Indexes for table `notes` -- ALTER TABLE `notes` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `user_id` (`user_id`,`page_id`); -- -- Indexes for table `orders` -- ALTER TABLE `orders` ADD PRIMARY KEY (`id`), ADD KEY `user_id` (`user_id`); -- -- Indexes for table `pages` -- ALTER TABLE `pages` ADD PRIMARY KEY (`id`), ADD KEY `creation_date` (`date_created`), ADD KEY `category` (`category`); -- -- Indexes for table `page_ratings` -- ALTER TABLE `page_ratings` ADD PRIMARY KEY (`user_id`,`page_id`); -- -- Indexes for table `pdfs` -- ALTER TABLE `pdfs` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `tmp_name` (`tmp_name`), ADD KEY `date_created` (`date_created`); -- -- Indexes for table `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `username` (`username`), ADD UNIQUE KEY `email` (`email`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `categories` -- ALTER TABLE `categories` MODIFY `id` smallint(6) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=6; -- -- AUTO_INCREMENT for table `history` -- ALTER TABLE `history` MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `notes` -- ALTER TABLE `notes` MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `orders` -- ALTER TABLE `orders` MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `pages` -- ALTER TABLE `pages` MODIFY `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=22; -- -- AUTO_INCREMENT for table `pdfs` -- ALTER TABLE `pdfs` MODIFY `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=4; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
  10. Well, it's 3 days later and still no idea why your code isn't working. It's looking for an index called category when there isn't one. 8. Validate the category: if (filter_var($_POST[‘category'], FILTER_VALIDATE_INT, -array('min_range' => 1))) { $cat = $_POST[‘category']; } else { // No category selected. $add_page_errors['category'] = 'Please select a category!'; } Here is the sql.sql we are running the add_page.php against: -- -- Table structure for table `categories` -- CREATE TABLE `categories` ( `id` SMALLINT NOT NULL AUTO_INCREMENT, `category` VARCHAR(30) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `category` (`category`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Dumping data for table `categories` -- INSERT INTO `categories` (`id`, `category`) VALUES (1, 'General Web Security'), (2, 'PHP Security'), (3, 'Common Attacks'), (4, 'JavaScript Security'), (5, 'Database Security'); -- -------------------------------------------------------- -- -- Table structure for table `orders` -- CREATE TABLE `orders` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `user_id` INT UNSIGNED DEFAULT NULL, `transaction_id` VARCHAR(19) NOT NULL, `payment_status` VARCHAR(15) NOT NULL, `payment_amount` DECIMAL(6,2) UNSIGNED NOT NULL, `payment_date_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `user_id` (`user_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Table structure for table `pages` -- CREATE TABLE `pages` ( `id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT, `category_id` SMALLINT UNSIGNED NOT NULL, `title` VARCHAR(100) NOT NULL, `description` TINYTEXT NOT NULL, `content` LONGTEXT NOT NULL, `date_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `category_id` (`category_id`), KEY `creation_date` (`date_created`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Dumping data for table `pages` -- INSERT INTO `pages` VALUES(1, 3, 'This is a Common Attack Article.', 'This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. ', '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>\r\n\r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit.\r\nAliquam tincidunt mauris eu risus.\r\nVestibulum auctor dapibus neque.\r\nNunc dignissim risus id metus.\r\nCras ornare tristique elit.\r\nVivamus vestibulum nulla nec ante.\r\n\r\n<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>', '2010-08-04 10:16:36'); INSERT INTO `pages` VALUES(2, 3, 'This is another Common Attack Article.', 'This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. ', '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>\r\n<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>', '2010-08-04 10:17:28'); -- -------------------------------------------------------- -- -- Table structure for table `pdfs` -- CREATE TABLE `pdfs` ( `id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, `tmp_name` CHAR(40) NOT NULL, `title` VARCHAR(100) NOT NULL, `description` TINYTEXT NOT NULL, `file_name` VARCHAR(40) NOT NULL, `size` MEDIUMINT UNSIGNED NOT NULL, `date_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `tmp_name` (`tmp_name`), KEY `date_created` (`date_created`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE `users` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `type` ENUM('member','admin') NOT NULL, `username` VARCHAR(30) NOT NULL, `email` VARCHAR(80) NOT NULL, `pass` VARBINARY(32) DEFAULT NULL, `first_name` VARCHAR(20) NOT NULL, `last_name` VARCHAR(40) NOT NULL, `date_expires` DATE NOT NULL, `date_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `date_modified` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`), UNIQUE KEY `username` (`username`), UNIQUE KEY `email` (`email`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- BONUS TABLES! -- -- -------------------------------------------------------- -- -- Table structure for table `history` -- CREATE TABLE history ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `user_id` INT UNSIGNED NOT NULL, `type` ENUM('page', 'pdf'), `page_id` MEDIUMINT UNSIGNED DEFAULT NULL, `pdf_id` SMALLINT UNSIGNED DEFAULT NULL, `date_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY (`page_id`, `type`), KEY (`pdf_id`, `type`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Table structure for table `notes` -- CREATE TABLE notes ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `user_id` INT UNSIGNED NOT NULL, `page_id` MEDIUMINT UNSIGNED NOT NULL, `note` TINYTEXT NOT NULL, `date_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE (`user_id`, `page_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Table structure for table `favorite_pages` -- CREATE TABLE favorite_pages ( `user_id` INT UNSIGNED NOT NULL, `page_id` MEDIUMINT UNSIGNED NOT NULL, `date_created` TIMESTAMP NOT NULL, PRIMARY KEY (`user_id`, `page_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Table structure for table `page_ratings` -- CREATE TABLE page_ratings( `user_id` INT UNSIGNED NOT NULL, `page_id` MEDIUMINT UNSIGNED NOT NULL, `rating` TINYINT UNSIGNED NOT NULL, `date_created` TIMESTAMP NOT NULL, PRIMARY KEY (`user_id`, `page_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  11. I'm having problems figuring out how to fix my "category not found error" on my add_page.php. This is a repost I believe of the same error Posted 25 February 2016 - 9:39 PM. Here is book code: 8. Validate the category: if (filter_var($_POST[‘category’], FILTER_VALIDATE_INT, array(‘min_range’ => 1))) { $cat = $_POST[‘category’]; } else { // No category selected. $add_page_errors[‘category’] = ‘Please select a category!’; } Each HTML page is in a single category. That association is made by attaching to each page record a foreign key to the proper value in the categories table. To confirm that the category value is an integer greater than, or equal to, 1, I’m again turning to PHP’s Filter extension. ---------------------------------------------------------------------------------------------------------------------- The problem I'm having is following the logic of selecting a category in the pulldown on the page, going to the categories table, checking if category is a number between 1-5, going to the pages table, inserting a row with the categories_id number assigned. To much going on. Categories, Category, Categories_id. Can't follow logic. Seems like if I rename something in the database it will work. My guess is this is a foreign key issue. I'm a student, how would I know. Category in categories table is trying to match to Categories_id in Pages table? Heck, I don't know. Note: I got the code to work locally if I rem out the $cat parameter in a few places but I'd like the code to work the way it was designed! Here is my MySQL database info. Note that for the pages table below I've manually added data for the five different categories (and it shows up fine in the page). I just can't add a page (row) through the add_page.php interface! Here is a dump of my Categories and Pages tables: -- -- Table structure for table `categories` -- CREATE TABLE IF NOT EXISTS `categories` ( `id` smallint(6) NOT NULL, `category` varchar(30) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ; -- -- Dumping data for table `categories` -- INSERT INTO `categories` (`id`, `category`) VALUES (1, 'General Web Security'), (2, 'PHP Security'), (3, 'Common Attacks'), (4, 'JavaScript Security'), (5, 'Database Security'); -- -- Indexes for table `categories` -- ALTER TABLE `categories` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `category` (`category`); -- -- Table structure for table `pages` -- CREATE TABLE IF NOT EXISTS `pages` ( `id` mediumint(8) unsigned NOT NULL, `categories_id` smallint(5) unsigned NOT NULL, `title` varchar(100) NOT NULL, `description` tinytext NOT NULL, `content` longtext NOT NULL, `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ; -- -- Dumping data for table `pages` -- INSERT INTO `pages` (`id`, `categories_id`, `title`, `description`, `content`, `date_created`) VALUES (1, 3, 'This is a Common Attack Article.', 'This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. ', '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>\r\n\r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit.\r\nAliquam tincidunt mauris eu risus.\r\nVestibulum auctor dapibus neque.\r\nNunc dignissim risus id metus.\r\nCras ornare tristique elit.\r\nVivamus vestibulum nulla nec ante.\r\n\r\n<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>', '2010-08-04 14:16:36'), (2, 5, 'This is a Database Security Article', 'This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. ', '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>\r\n<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>', '2010-08-04 14:17:28'), (3, 1, 'This is a General Web Security Article.', 'This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. ', '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>\r\n<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>', '2010-08-04 14:17:28'), (4, 4, 'This is a JavaScript Security Article.', 'This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. ', '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>\r\n<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>', '2010-08-04 14:17:28'), (5, 2, 'This is a PHP Security Article.', 'This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. This is the description. ', '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>\r\n<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.<br /><br />Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>', '2010-08-04 14:17:28'); -- -- Indexes for dumped tables -- -- -- Indexes for table `pages` -- ALTER TABLE `pages` ADD PRIMARY KEY (`id`), ADD KEY `creation_date` (`date_created`), ADD KEY `categories_id` (`categories_id`); After you fill out the form and press the add button the error shows up below. The text fields are still filled in but the category you chose is not selected in the error message page:
×
×
  • Create New...