Jump to content
Larry Ullman's Book Forums

krobinson937

Members
  • Posts

    10
  • Joined

  • Last visited

krobinson937's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. All, on page 277 creating pagination, how can or what is the best way to customize this script for articles or any other content wanting to be displayed through pagination. Please help.
  2. <link href="../css/styles.css" rel="stylesheet" type="text/css" /> <style id='flashfirebugstyle' type='text/css'>object,embed{visibility:hidden !important;}</style></head> <body> <div id="wrap"> <div class="header"> <!-- TITLE --> <h1><a href="index.php">Knowledge is Power</a></h1> <h2>and it pays to know</h2> <!-- END TITLE --> </div> <div id="nav"> <ul> <!-- MENU --> <?php // Dynamically create header menus... // Array of labels and pages (without extensions): $pages = array ( 'Home' => 'index.php', 'About' => 'about.php', 'Contact' => 'contact.php', 'Register' => 'register.php' ); // The page being viewed: $this_page = basename($_SERVER['PHP_SELF']); // Create each menu item: foreach ($pages as $k => $v) { // Start the item: echo '<li'; // Add the class if it's the current page: if ($this_page == $v) echo 'class="selected"'; // Complete the item: echo '><a href="' . $v . '"><span>' . $k . '</span></a></li> '; } // End of FOREACH loop. ?> <!-- END MENU --> </ul> </div> <div class="page"> <div class="content"> <!-- CONTENT --> Yes, it could be (class = "selected")-**blue text** kinda strange in code view, but I guess. But why are the codes being displayed vs the links and tabs (images). I have check several times too make sure that I have not left nothing out or mistype any codes. Then I just copied from source files and still get the codes displaying not the links and tab images. The page heading is displaying along with the color that's outline in the css file. I will troubleshoot some more, maybe I'm still doing something wrong.
  3. Once I realized what I had just did, I change them. Thanx.
  4. ********config.php********* <?php $live = false; $contact_email = 'you@example'; define('BASE_URI', 'http://localhost/effortless_e-commerce/'); // define('BASE_URI', 'includes/pdf'); define('BASE_URL', 'www.example.com/'); define('MYSQL', BASE_URI . 'mysql.inc.php'); session_start(); // Begin defining an error-handling function: function my_error_handler($e_number, $e_message, $e_file, $e_line, $e_vars) { global $live, $contact_email; // Begin creating a detailed error message: $message = "An error occurred in script '$e_file' on line $e_line:\n$e_message\n"; // Add the backtrace information: $message .= "<pre>" .print_r(debug_backtrace(), 1). "</pre>\n"; // Or just append $e_vars to the message: // $message .= "<pre>" . print_r ($e_vars, 1) . "</pre>\n"; if(!$live) { echo '<div class="error">' .nl2br($message). '</div>'; // If the site is live, send the error in an email: } else { error_log($message, 1, $contact_email, 'From:admin@example.com'); if($e_number != E_NOTICE) { echo '<div class="error">A system error occurred. We apologize for the inconvenience.</div>'; } } // End of $live If-ELSE. return true; } // End of my_error_handler() definition. //***************************************** /* This line actually tells php to use the customer function for handling errors. If you don't execute this function call, then PHP will still use its default handler. This is also why a parse error won't go through your own error handler, because the parse error prevents the PHP script from being exectued. */ set_error_handler('my_error_handler'); ?> **********index.php************ <?php require('./includes/config.inc.php'); require(MYSQL); include('./includes/header.html'); // page-specific content: ?><h3>Welecome</h3> <p>Welecome to Knowledge is Power, a site dedicated to keeping you up to date on the Web security and programming information you need to know. Blah, blah, blah, Yadda, yadda, yadda.</p> <?php include('./includes/footer.html'); ?> *******mysql.inc.php****** <?php // This file contains the database access information. // This file establishes a connection to MySQL and selects the database. // This file defines a function for making data safe to use in queries. // This file defines a function for hashing passwords. // This script is begun in Chapter 3. // Set the database access information as constants: DEFINE ('DB_USER', 'ruby711'); DEFINE ('DB_PASSWORD', 'jaela711'); DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_NAME', 'ecommerce1'); // Make the connection: $dbc = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Set the character set: mysqli_set_charset($dbc, 'utf8'); // Function for escaping and trimming form data. // Takes one argument: the data to be treated (string). // Returns the treated data (string). function escape_data ($data) { global $dbc; // Database connection. // Strip the slashes if Magic Quotes is on: if (get_magic_quotes_gpc()) $data = stripslashes($data); // Apply trim() and mysqli_real_escape_string(): return mysqli_real_escape_string ($dbc, trim ($data)); } // End of the escape_data() function. // This next block is added in Chapter 4. // This function returns the hashed version of a password. // It takes the user's password as its one argument. // It returns a binary version of the password, already escaped to use in a query. function get_password_hash($password) { // Need the database connection: global $dbc; // Return the escaped password: return mysqli_real_escape_string ($dbc, hash_hmac('sha256', $password, 'c#haRl891', true)); } // End of get_password_hash() function. // Omit the closing PHP tag to avoid 'headers already sent' errors! ?> My index.php is in the root dir and my includes is the root dir along supporting files.
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php // Use a default page title if one wasn't provided... if (isset($page_title)) { echo $page_title; } else { echo 'Knowledge is Power: And It Pays to Know'; } ?></title> <link href="../css/styles.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="wrap"> <div class="header"> <!-- TITLE --> <h1><a href="index.php">Knowledge is Power</a></h1> <h2>and it pays to know</h2> <!-- END TITLE --> </div> <div id="nav"> <ul> <!-- MENU --> <?php // Dynamically create header menus... // Array of labels and pages (without extensions): $pages = array ( 'Home' => 'index.php', 'About' => 'about.php', 'Contact' => 'contact.php', 'Register' => 'register.php' ); // The page being viewed: $this_page = basename($_SERVER['PHP_SELF']); // Create each menu item: foreach ($pages as $k => $v) { // Start the item: echo '<li'; // Add the class if it's the current page: if ($this_page == $v) echo ' class="selected"'; // Complete the item: echo '><a href="' . $v . '"><span>' . $k . '</span></a></li> '; } // End of FOREACH loop. ?> <!-- END MENU --> </ul> </div> <div class="page"> <div class="content"> <!-- CONTENT -->
  6. 'index.php', 'About' => 'about.php', 'Contact' => 'contact.php', 'Register' => 'register.php' ); // The page being viewed: $this_page = basename($_SERVER['PHP_SELF']); // Create each menu item: foreach ($pages as $k => $v) { // Start the item: echo '' . $k . ' '; } // End of FOREACH loop. ?> Instead of text links being displayed on header.html, the above text is being displayed. Ken
  7. An error occurred in script 'C:\XAMPP\htdocs\effortless_e-commerce\index.php' on line 5: require(effortless_e-commercemysql.inc.php) [function.require]: failed to open stream: No such file or directory Array ( [0] => Array ( [file] => C:\XAMPP\htdocs\effortless_e-commerce\index.php [line] => 5 [function] => my_error_handler [args] => Array ( [0] => 2 [1] => require(effortless_e-commercemysql.inc.php) [function.require]: failed to open stream: No such file or directory [2] => C:\XAMPP\htdocs\effortless_e-commerce\index.php [3] => 5 [4] => Array ( [GLOBALS] => Array *RECURSION* [_POST] => Array ( ) [_GET] => Array ( ) [_COOKIE] => Array ( [phpSESSID] => bqhon059t4qre5rf1trpcqjt96 ) [_FILES] => Array ( ) [live] => [contact_email] => you@example [_SESSION] => Array ( ) ) ) ) [1] => Array ( [file] => C:\XAMPP\htdocs\effortless_e-commerce\index.php [line] => 5 [function] => require ) ) Fatal error: require() [function.require]: Failed opening required 'effortless_e-commercemysql.inc.php' (include_path='.;C:\XAMPP\php\PEAR') in C:\XAMPP\htdocs\effortless_e-commerce\index.php on line 5 <?php // This file contains the database access information. // This file establishes a connection to MySQL and selects the database. // This file defines a function for making data safe to use in queries. // This file defines a function for hashing passwords. // This script is begun in Chapter 3. // Set the database access information as constants: DEFINE ('DB_USER', 'ruby711'); DEFINE ('DB_PASSWORD', 'jaela711'); DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_NAME', 'ecommerce1'); // Make the connection: $dbc = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Set the character set: mysqli_set_charset($dbc, 'utf8'); // Function for escaping and trimming form data. // Takes one argument: the data to be treated (string). // Returns the treated data (string). function escape_data ($data) { global $dbc; // Database connection. // Strip the slashes if Magic Quotes is on: if (get_magic_quotes_gpc()) $data = stripslashes($data); // Apply trim() and mysqli_real_escape_string(): return mysqli_real_escape_string ($dbc, trim ($data)); } // End of the escape_data() function. // This next block is added in Chapter 4. // This function returns the hashed version of a password. // It takes the user's password as its one argument. // It returns a binary version of the password, already escaped to use in a query. function get_password_hash($password) { // Need the database connection: global $dbc; // Return the escaped password: return mysqli_real_escape_string ($dbc, hash_hmac('sha256', $password, 'c#haRl891', true)); } // End of get_password_hash() function. // Omit the closing PHP tag to avoid 'headers already sent' errors! ?>
  8. No definition, just outline on page 65 4.Create an array of pages: $pages = array( 'Home' => 'index.php', 'About' => 'about.php', 'Contact' => 'contact.php', 'Register' => 'register.php' ); Home link stays blue and all other links turns black. Keep in mind I'm using DW3.
  9. I'm fine with PHP, we are using your PHP and MySQL @ Cincinnati State, also have I all your latest books. I'm using DW3 for design tool. On page 65 when setting up the array for home, about, contact, and register; the home text stays blue and all other text turn black. I have look for any missing quotes or other mis-type syntax, finally, I just copied header.html from source files. Another issue, I'm having problems with my css/images (the tab images) not showing up on main nav when viewing from in preview mode from Dreamweaver 3. I have check my file structure.
  10. I'm having problems with my text or syntax. I'm currently working on page 65, when I go to setup the array for the list some words are blue and are black. When I go to display header.html in firfox, I see the raw code in browser not the tabs nor text color outline by style sheet. Any ideas? Ken
×
×
  • Create New...