SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    query not inserting (this one is wierd)

    I have been making a script, went to bed last night it was all working fine I get up this morning and 1 of the queries is not inserting into the database.

    The wierd part is its updating the auto inc key on the table but not inserting anything at all not even empty fields etc.

    I have used echo to put the query onto the page then run that query manually in phpmyadmin and it inserts fine.

    the databsae link from my php file is definatly valid because not only is it updating the primary key after the query I check how many rows was affected and it passes.

    here is the query

    INSERT INTO traveling (players_id,locations_id,time_left) VALUES (1,4,"2008-06-04 2:34 ")
    thanks

  2. #2
    secure webapps for all Aleksejs's Avatar
    Join Date
    Apr 2008
    Location
    Riga, Latvia
    Posts
    755
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi!
    What is your table structure? I.e. what does query:
    Code sql:
    SHOW CREATE TABLE traveling;
    return?

  3. #3
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the reply here is what it brings up

    CREATE TABLE `traveling` (
    `traveling_id` bigint(20) NOT NULL auto_increment,
    `players_id` bigint(20) NOT NULL,
    `locations_id` int(11) NOT NULL,
    `time_left` varchar(100) NOT NULL,
    PRIMARY KEY (`traveling_id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1

  4. #4
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if I run my query (from the PHP script) no data at all will be inserted not even empty values, but the AUTO_INCREMENT field will go up 1

    Code:
    CREATE TABLE `traveling` (
    `traveling_id` bigint(20) NOT NULL auto_increment,
    `players_id` bigint(20) NOT NULL,
    `locations_id` int(11) NOT NULL,
    `time_left` varchar(100) NOT NULL,
    PRIMARY KEY (`traveling_id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1

  5. #5
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok this is even more wierd,

    my query is now working and the only thing that has changed is the time

    Code:
    INSERT INTO traveling (players_id,locations_id,time_left) VALUES (1,4,"2008-06-04 2:12 ")
    that is the oringal query which will not run, now because alot of time has gone by since I have been trying to find a fix the date has changed + 1 hour

    Code:
    INSERT INTO traveling (players_id,locations_id,time_left) VALUES (1,4,"2008-06-04 3:22 ")
    that query runs fine just because of the change in time at the end, but its storing as a string so I cant see what difference it makes?

    To test it I put my server clock back by 1 hour and the breaks the query again

  6. #6
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Neller View Post
    if I run my query (from the PHP script) no data at all will be inserted not even empty values, but the AUTO_INCREMENT field will go up 1
    you're opening a transaction but never committing it.
    Check out our new Industry News forum!
    Keep up-to-date with the latest SP news in the Community Crier

    I edit the SitePoint Podcast


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
  •