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
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 Display Modes
  #1 (permalink)  
Old April 3rd, 2012, 09:34 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default lesson28csfinal error

Why would the programme/website (lesson28csfinal) in lesson 28 in the book of <PHP and MySQl 24-Hour Trainer> , UNABLE TO EDIT CONTACT INFO VIA WEBSITE?
Reply With Quote
  #2 (permalink)  
Old April 5th, 2012, 12:02 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

I found the problem in the contact.php file.
In Chapter 28, in Step 8, 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) . "'";
I'm really sorry for the frustration this will have given you.
Reply With Quote
  #3 (permalink)  
Old April 6th, 2012, 12:55 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Problem solved and apologies accepted.
I'm happy with the service!
With best wishes for you and the organization continued success.
Reply With Quote
  #4 (permalink)  
Old September 22nd, 2013, 06:54 PM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default php & mysql 24hour trainer chapter30

Please can anybody guide me on how to separate admin menu and public menu?
Thanks
Reply With Quote
Reply


Thread Tools
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
SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified soufya BOOK: Beginning ASP.NET 4 : in C# and VB 7 September 14th, 2011 08:08 AM
HTTP error 500: Internal Server Error in Load Testing sherin Visual Studio 2008 0 May 19th, 2010 09:02 AM
Remote Connection Error: Named Pipes Provider error hbansal ASP.NET 2.0 Basics 5 April 12th, 2009 09:51 AM
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM



All times are GMT -4. The time now is 01:55 AM.


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