Results 1 to 4 of 4

Thread: Insert into fails using PHP and MySQL with no errors

  1. #1
    Join Date
    Mar 2009
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Insert into fails using PHP and MySQL with no errors

    I have been going crazy and need some good ideas how to debug this probem?

    I am using mysql and php and the problem is i get to about half way through my inserts and the insert fail - I am using auto increment and a select that goes through the whole table and inside the while loop I hold some veriables in the results set.

    I am able to insert a large number of records but then when I get to the middle of my process i seem to have my insert fail with no error messages the script jsut stops.

    I am using 5.0.5 dev of mysql if that helps and php 5.31 i strip my insert down to just inserting the one field and the auto increment should happen automatictly so it is not my data that is the problem but the auto increment field its self.

    Here is the table structure that i am inserting in to

    $mytabletemp = "CREATE TABLE ALEPPOEXTRA (
    ememid int unsigned NOT NULL AUTO_INCREMENT,
    MemNumE VARCHAR(10),
    First VARCHAR(50),
    Middle VARCHAR(50),
    Last VARCHAR(50),
    Suffix VARCHAR(5),
    Address1 VARCHAR(50),
    Address2 VARCHAR(50),
    City VARCHAR(35),
    State VARCHAR(2),
    Zip VARCHAR(10),
    Birthdate VARCHAR(10),
    YearBirth VARCHAR(10),
    DayBirth VARCHAR(10),
    MonthBirth VARCHAR(10),
    Birth VARCHAR(10),
    PRIMARY KEY (ememid) )";

    I have tried the int unsigned and just int i do not get any further in my inserts.

    The select is this

    $mycommand = "SELECT M.Memkey, A.Memkey, A.AddressAutoID, M.MemNum, M.StatusType, M.FirstName, M.MiddleName, M.LastName, M.Suffix, A.Address1, A.Address2, A.City, A.State, A.Zip, M.DOB FROM ALEPPOMEMBERS M, ALEPPOADDRESS A WHERE ( M.Memkey = A.AddressAutoID ) AND ( NOT M.Memkey = A.Memkey ) AND NOT M.StatusType = 'C'";

    $retquery1 = mysql_query( $mycommand, $mysql_connection );
    if (mysql_errno()) {
    echo "Could not Query or Error Occured while : " . mysql_errno() . ": " . mysql_error(). "\n";
    exit(0);
    }

    while ($rowouter = mysql_fetch_row($retquery1)) {


    $queryextra = "INSERT INTO ALEPPOEXTRA SET MemNumE = '$rowouter[0]'";

    $retvalA = mysql_query($queryextra, $mysql_connection);
    if (mysql_errno()) { // - fhs 02/19/2010
    echo "Could not Insert Aleppo Members and Address EXTRA into Aleppo table: " . mysql_errno() . ": " . mysql_error(). "\n";
    exit(0);
    } // - fhs 02/19/2010



    }

    I have strip a lot of stuff out of the above to boil the problem down to very basic things.

    The touble is the failure seems to happen on 2436 or there abouts - the failure seems to not be the same each time I run the query and insert but only a few records apart how ever.

    Any one have some ideas as to what i might look at to resolve this strange problem.

    TAHNKS

    Frank H. Shaw

  2. #2
    Join Date
    Jun 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Same here. Did you find where was the problem? Now it's me who is getting crazy trying to find this annoying bug...

  3. #3
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Post the error message that you are getting.

    Most likely this is due to inserting a row into a table at a location where there is already a row in place. This can come about when trying to recycle tables. To get around this you can either insert after the last inserted row or write a short php script to insert in locations only where there is no data. You can also just empty the table before inserting anything.
    To choose the lesser of two evils is still to choose evil. My personal site

  4. #4
    Join Date
    Mar 2009
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile I think I resolved this by changing the autoincrment field type

    It is been a long time since i posted this problem and if my memory server's me right i think i changed the auto increment to a different type if feild so it held a larger interenal autoincrement number the trouble thus project is long gone and i did get it finshed and when i get some free time i will try to look through my notes and post the fix as soon as i can. THANKS

Bookmarks

Posting Permissions

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