Rod Rig Gez
Rod Rig Gez

Reputation: 133

Auto_increment option doesn't work on server

Need your help, strange. I have the same tables based locally and on the server - the one on the server doesn't increment ? The local one does...here's the SQL statement for the colum. I can only register / input one row when there are no data, then it doesn't auto increment on next submissions:

-- phpMyAdmin SQL Dump
-- version 3.3.9.2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Oct 25, 2011 at 01:31 PM
-- Server version: 5.0.92
-- PHP Version: 5.2.6

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `name`
--

-- --------------------------------------------------------

--
-- Table structure for table `basic`
--

   CREATE TABLE IF NOT EXISTS `basic` (
  `user_id` int(11) NOT NULL auto_increment,
  `username` varchar(255) character set utf8 NOT NULL,
  `email` varchar(255) character set utf8 NOT NULL,
  `email_active` enum('1','0') character set utf8 NOT NULL default '0',
  `password` varchar(128) character set utf8 NOT NULL,
  PRIMARY KEY  (`user_id`),
  UNIQUE KEY `email` (`email`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `basic`
--

INSERT INTO `basic` (`user_id`, `username`, `email`, `email_active`, `password`) VALUES
(2, 'mrd', '[email protected]', '0', '05cb6e7ad0f2a84ee6b1cc097dbf2787');

Why does it work locally ? (I'm using PHP my admin on the server and locally as well )

Thank you...

Upvotes: 1

Views: 276

Answers (1)

SeanCannon
SeanCannon

Reputation: 77996

Make sure you set the AUTO_INCREMENT flag:

CREATE TABLE users
(
user_id int NOT NULL AUTO_INCREMENT,
username varchar(255) NOT NULL,
email varchar(255) UNIQUE,
email_active TINYINT(1),
password varchar(12),
PRIMARY KEY (user_id)
)

Upvotes: 2

Related Questions