Wrox Programmer Forums
|
BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9
This is the forum to discuss the Wrox book PHP and MySQL: Create-Modify-Reuse by Timothy Boronczyk, Martin E. Psinas; ISBN: 9780470192429
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 9th, 2010, 07:49 AM
Authorized User
 
Join Date: Apr 2010
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default figured out my problem

Okay, I figured out why nothing was getting written to the database, and it was so obvious I can't believe it took me an entire day to notice it. I had named the include file db.inc.php (force of habit from a previous PHP class) and all the pages in this book are using an include file named db.php. I just needed to rename db.inc.php to db.php and now everything seems to be working just fine.
Sometimes it is the simple things that we overlook without even realizing it that will mess up our programming. That's why these forums are so helpful.
 
Old March 7th, 2011, 03:06 PM
Registered User
 
Join Date: Mar 2011
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via MSN to GallowayAC
Default UID Issue

Further down in the thread there was discussion of the "uid" associated with the token being 0 and how that was an issue. When I put my information in and submit there is absolutely no "uid" associated with the token.

Quote:
Be sure to verify your account by visiting verify.php?uid=&token=5DPPM
I have looked through register.php, verify.php, and user.php and cannot seem to find the issue. The information is populating in wrox_user and wrox_pending. Where am I going wrong?
 
Old March 26th, 2011, 01:35 PM
Authorized User
 
Join Date: Jul 2009
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default UID Issue

Hi GallowayAC,

Try to trace it back.

On page 15, about line 7, you are
instantiating a user object.
PHP Code:
  $user = new User(); 
On that same page, about 5 lines further down,
you are calling the method setInactive().
PHP Code:
  $token $user->setInactive(); 
At this point, you do not have a user id yet,
but you will have one after returning from this method.

Let's look at the setInactive method.
It starts on page 8, about line 9.
PHP Code:
   public function setInactive() 
In this method you call the method save().
This is on page 8, about line 12
PHP Code:
   $this->save(); 
"$this" refers to the user object you instantiated up above.
You still do not have a user id yet, but you will have one
after returning from this method.

Let's look at the save method
It starts on page 7, about line 23
PHP Code:
    public function save() 
As you enter this method you do not have a userid, so
you will enter the else block. Assuming your query is
successful, you drop into the nested if statement
to the line
PHP Code:
     $this->uid mysql_insert_id($GLOBALS(['DB']); 
This is the point where the user id is generated. When this statement
is done executing successfully you will have your user id
for the user you instantiated up above (As I said "$this" refers
to that object)

Put a print statement before this statement and make sure you
are getting to this line of code.
Put another print statement right after this line and print the
user id. Run your program a couple of times and
verify that you are getting reasonable user ids that keep
incrementing on each run of your program. If not check that
you have set up your database tables correctly. In the WROX_USER
table make sure USER_ID has AUTO_INCREMENT.

If this line of code is successful, then put in print statements along the way
through the flow of logic mentioned above and see where your
user id disappears.

Based on what you have said, that you had the correct information in the
pending table, it seems you were successful in the setInactive method. You
are probably losing the value higher up in the logic flow. Your problem
would not be in verify.php as you are not passing it a good userid. You call
to verify should have something like this
PHP Code:
     verify.php?uid=5&token=5DPPM 
See the post ch1 userId, about the second reply down.
There is a discussion about the line
PHP Code:
     $this->uid mysql_insert_id($GLOBALS(['DB']); 
In that reply there is also a discussion about the
use of $this->userId and $this->uid

There are some mistakes in Chapter 1. Check the errata
and be sure to make those changes.

I hope this helps.
The Following User Says Thank You to kenj For This Useful Post:
GallowayAC (March 29th, 2011)
 
Old May 31st, 2011, 11:09 AM
Authorized User
 
Join Date: May 2011
Posts: 12
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Similar problems.

I have looked at the comments and checked the programming accordingly, but when I run it I get the following error_log 'supplied argument is not a valid MySQL result resource'. This refers to mysql_num_rows and mysql_free_results found in the function getByUsername(username). Any suggestions as to why and how I can fix it?

Thanks


Albion
 
Old May 31st, 2011, 12:13 PM
Authorized User
 
Join Date: May 2011
Posts: 12
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Panic over! I sussed it out. It was simply a matter of capitals and lowercase discrepancies. Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 5 - Command Line Error. Invalid parameter dbaechtel BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 0 August 11th, 2009 11:00 AM
Chapter 8,Invalid authorization omom2002 BOOK: Beginning VB.NET Databases 1 May 27th, 2008 05:04 AM
Cant seem to compile (small with source provided) noob1 JSP Basics 1 September 20th, 2003 03:55 AM
cannot check data provided by a form scifo Beginning PHP 1 August 6th, 2003 11:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.