Results 1 to 3 of 3

Thread: Auto Incremet Query is not working

  1. #1
    Join Date
    Jan 2013
    Location
    Pakistan
    Posts
    1

    Post Auto Incremet Query is not working

    Hey dears, I have a problem with my auto increment feature of mysql. I have set my user_id field as a primary key and also auto increment . But it is not working. What are possible errors. Remeber one thing i am doing it with php. Please help me!

  2. #2
    Join Date
    Apr 2014
    Posts
    1
    There could be a number of causes for this error if you are using PHP, but I would start at the SQL level to make sure you know what your increment value is set to. You can do this with the following command:

    ALTER TABLE <TABLE NAME HERE> AUTO_INCREMENT = 1;

    This will set the value to 1 and you can work from there on, so you know what to expect in your php variable. Are you using a MySQL function to retrieve the result set of you sql query and then assign the increment result to a php $variable?

    Regards,

    http://www.freemysql.org

  3. #3
    Join Date
    May 2014
    Posts
    3
    Shahnawaz,
    When you create table, you sould have something like this:
    CREATE TABLE mytable (
    id MEDIUMINT NOT NULL AUTO_INCREMENT,
    name CHAR(30) NOT NULL,
    PRIMARY KEY (id)
    ) ENGINE=MyISAM;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •