Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: PHP and MySQL 24-Hour Trainer
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: PHP and MySQL 24-Hour Trainer
This is the forum to discuss the Wrox book PHP and MySQL 24-Hour Trainer by Andrea Tarr ; ISBN: 978-1-1180-6688-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: PHP and MySQL 24-Hour Trainer section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 7th, 2013, 02:19 PM
Tarrconsulting's Avatar
Wrox Author
Points: 50, Level: 1
Points: 50, Level: 1 Points: 50, Level: 1 Points: 50, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2011
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Errata from author

This is a thread that contains errata found in PHP and MySQL 24-Hour Trainer.

4/5/2012

Chapter 7, Step 5

The code shown is:
Code:
	<div class="sidebar">
		<?php 
    		switch (isset($_GET['content'])):
            case 'gents' :
            case 'sporting' :
            case 'women' :
    		  include 'content/catnav.php';
    		endswitch;
		?>
	</div><!-- end sidebar -->
This code should be:
Code:
	<div class="sidebar">
		<?php 
		if (isset($_GET['content'])) :
    		switch ($_GET['content']):
            case 'gents' :
            case 'sporting' :
            case 'women' :
    		  include 'content/catnav.php';
    		endswitch;
		endif;
		?>
	</div><!-- end sidebar -->
In Chapter 28, in Step 8, there is a problem with the includes/contact.php file. I have you add a condition to the _verifyInput function that checks to see if the username is already in use. Since this function is used both when you add a record and when you change a record, we should only check this when you are adding a record.
Code:
  if (!trim($this->user_name)) {
     $error = true;
  } elseif (strlen(trim($this->user_name)) < 6) {
     $error = true;
  } elseif ($this->id==0 AND self::getContactIdByUser(trim($this->user_name))) {
    $error = true;
  }
You'll see that I added "$this->id==0 AND " to that condition so that only new records will be checked.

There is also another error in this file. In Step 10, where we construct the password hash in the addRecord function, the query statement to add the username and password hash is incorrect. It should have a WHERE clause and should be using the mysqli (rather than the mysql) function to get the last id added. This is what it should look like:

Code:
      if ($connection->query($query)) { // this inserts the row
        // update with the user name and password now that you know the id
        $query = "UPDATE contacts 
        SET user_name = '" . Database::prep($this->user_name) . "', 
        password = '" . hash_hmac('sha512',
          $password . '!hi#HUde9' . mysqli_insert_id($connection), 
          SITE_KEY) ."',
        access = '" . Database::prep($this->access) . "'
        WHERE id = '" . mysqli_insert_id($connection) . "'";
4/11/2012

Chapter 6
The strftime format code %e is not supported by Windows and will give you a Warning message starting with "Warning: Invalid CRT parameters detected." You can replace it with %#d instead.

%e shows the day without leading zeros 1-31
%d shows the day with leading zeros 01-31
%#d shows the day without the leading zeros 1-31

If you don't care if a leading zero shows, you could just replace the %e with %d

4/12/2012
Chapter 6
lesson06x.php

The Notice error is happening because the first time you open the file the form hasn't been submitted so there are no GET's defined yet. To get rid of these errors when we need to check first that the GET's are defined. We can do that with the isset() function.

Replace the <p></p> line with this:

Code:
<?php if (isset($_GET["username"]) AND isset($_GET["password"])) : ?>
	<p>You entered <?php echo $_GET["username"] ?> as the User Name and <?php echo $_GET["password"] ?> as the Password.</p>
<?php else: ?>
	<p>Please enter your User Name and Password.</p>
<?php endif; ?>
This was just an example and you'll find as you go on we start adding in more robust features.

If there are additional Errata, they will be added to this thread.

Thanks,
Andrea Tarr
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Appendix - for the Author uberfist BOOK: Beginning VB.NET Databases 5 February 16th, 2006 06:09 PM
need help from author akshay_git All Other Wrox Books 1 March 28th, 2005 12:01 PM



All times are GMT -4. The time now is 02:01 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.