p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 (http://p2p.wrox.com/forumdisplay.php?f=160)
-   -   Chapter 12 - problem with "user_info" table (http://p2p.wrox.com/showthread.php?t=32311)

rdwheless1 August 9th, 2005 10:16 AM

Chapter 12 - problem with "user_info" table
 
The problem I am having with the "user_info" table is that when a new user registers an account, the user id is allways "0". Is this by design? Shouldn't each user have a unique id like the admin accounts?

//create "user_info" table
$user_info = "CREATE TABLE user_info (
  email varchar(50) NOT NULL,
  username varchar(50) NOT NULL,
  password varchar(255) NOT NULL,
  first_name varchar(50) NOT NULL,
  last_name varchar(50) NOT NULL,
  city varchar(50) default NULL,
  state varchar(50) default NULL,
  hobbies varchar(255) default NULL,
  id int(100) NOT NULL default '0',
)";

//create "admin" table
$admin = "CREATE TABLE admin (
  username varchar(50) NOT NULL,
  password varchar(255) NOT NULL,
  first_name varchar(50) NOT NULL,
  last_name varchar(50) NOT NULL,
  email varchar(50) NOT NULL,
  admin_level int(2) NOT NULL,
  id int(100) NOT NULL auto_increment,
  PRIMARY KEY (id),
)";


PHPMyAdmin tells me that there can only be one column with auto_increment. Has anyone else experienced this?

This is causing a problem later when I create the update_user.php on page 406. When I try to update the data for an individual user. The data for all users with id "0" gets updated.

Thanks for any help. -Ronald

d2nash June 16th, 2006 03:46 PM

I just discovered the same issue ... not found a way around it yet though!

d2nash June 17th, 2006 05:20 AM

You need to set the ID column for the user_info table to Primary - then you can set it to auto_increment. You may need to update any data you have in this column to be unique before being able to set it to Primary.


All times are GMT -4. The time now is 02:03 AM.

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