php import to table failing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • GarryJones

    php import to table failing

    (I am sorry if this is the wrong group for this posting, I cant find a
    group on usenet for phpmyadmin, but maybe someone would be nice enough
    to answer me anyway....)

    I need to import data into a simple table The table has three fields.
    The first is an auto increment value, the second the current time and
    date (the 14 character version), and a field with some data.

    This works okay in SQL mode
    INSERT INTO all_epst VALUES ('',NOW(),'info test1');
    INSERT INTO all_epst VALUES ('',NOW(),'info test2');

    Using phpmyadmin I want to import this data from a csv file rather
    than the workaround of creating sql script

    Trouble is I cant get "current timestamp" to work. When I click on
    import in phpmyadmin I can choose "csv" or "csv mha"
    I try csv and set
    row end to ;
    field surround to '
    field seperator to ,

    The txt file for csv import contains
    '',NOW(),'infot est1';'',NOW(), 'infotest2';

    It imports the data and gives me the autoincrement value but the time
    stamp is left as 0000-00-00 00:00:00

    Feedback:
    INSERT INTO `all_epst`
    VALUES (
    '', 'NOW()', 'infotest1'
    )

    INSERT INTO `all_epst`
    VALUES (
    '', 'NOW()', 'infotest2'
    )

    I tried another txt file with
    '','','infotest 1';'','','infot est2';
    Again, it imports the data and gives me the autoincrement value but
    the time stamp is left as 0000-00-00 00:00:00
    VALUES (
    '', '', 'infotest1'
    )
    INSERT INTO `all_epst`
    VALUES (
    '', '', 'infotest2'
    )

    Note that the tabel is correctly structered with "CURRENT_TIMEST AMP"
    as the default. The attribute ("ON UPDATE CURRENT_TIMESTA MP" is not
    applicable as I am adding new values, but is set anyway.)

    What am I missing? How do I import with a csv text file using
    phpmyadmin?

    Any help greatfully appreciated
    Garry Jones
    Sweden
  • Mason Barge

    #2
    Re: php import to table failing


    "GarryJones " <morack@algonet .sewrote in message
    news:52656cb5-0b67-46e3-adc5-3476183db5e8@u6 9g2000hse.googl egroups.com...
    (I am sorry if this is the wrong group for this posting, I cant find a
    group on usenet for phpmyadmin, but maybe someone would be nice enough
    to answer me anyway....)
    >
    I need to import data into a simple table The table has three fields.
    The first is an auto increment value, the second the current time and
    date (the 14 character version), and a field with some data.
    >
    This works okay in SQL mode
    INSERT INTO all_epst VALUES ('',NOW(),'info test1');
    INSERT INTO all_epst VALUES ('',NOW(),'info test2');
    >
    Using phpmyadmin I want to import this data from a csv file rather
    than the workaround of creating sql script
    >
    Trouble is I cant get "current timestamp" to work. When I click on
    import in phpmyadmin I can choose "csv" or "csv mha"
    I try csv and set
    row end to ;
    field surround to '
    field seperator to ,
    >
    The txt file for csv import contains
    '',NOW(),'infot est1';'',NOW(), 'infotest2';
    >
    It imports the data and gives me the autoincrement value but the time
    stamp is left as 0000-00-00 00:00:00
    >
    Feedback:
    INSERT INTO `all_epst`
    VALUES (
    '', 'NOW()', 'infotest1'
    )
    >
    INSERT INTO `all_epst`
    VALUES (
    '', 'NOW()', 'infotest2'
    )
    >
    I tried another txt file with
    '','','infotest 1';'','','infot est2';
    Again, it imports the data and gives me the autoincrement value but
    the time stamp is left as 0000-00-00 00:00:00
    VALUES (
    '', '', 'infotest1'
    )
    INSERT INTO `all_epst`
    VALUES (
    '', '', 'infotest2'
    )
    >
    Note that the tabel is correctly structered with "CURRENT_TIMEST AMP"
    as the default. The attribute ("ON UPDATE CURRENT_TIMESTA MP" is not
    applicable as I am adding new values, but is set anyway.)
    >
    What am I missing? How do I import with a csv text file using
    phpmyadmin?
    >
    Any help greatfully appreciated
    Garry Jones
    Sweden
    That's hard to figure out second-hand. My best suggestion is to eliminate
    the "field surround" element, which you shouldn't need as long as the field
    doesn't contain a comma. The feedback you got shows value 'NOW()', but
    what you need (I think) is NOW() without single quotes around it. So I
    suspect the field surround is supplying single quotes and then mysql is
    reading it as a string rather than a function.

    You also might try setting a default to NOW() instead of just relying on the
    phpmydamin checkbox.

    Another suggestion is to check the encoding of your source.

    Comment

    • Jerry Stuckle

      #3
      Re: php import to table failing

      GarryJones wrote:
      (I am sorry if this is the wrong group for this posting, I cant find a
      group on usenet for phpmyadmin, but maybe someone would be nice enough
      to answer me anyway....)
      >
      I need to import data into a simple table The table has three fields.
      The first is an auto increment value, the second the current time and
      date (the 14 character version), and a field with some data.
      >
      This works okay in SQL mode
      INSERT INTO all_epst VALUES ('',NOW(),'info test1');
      INSERT INTO all_epst VALUES ('',NOW(),'info test2');
      >
      Using phpmyadmin I want to import this data from a csv file rather
      than the workaround of creating sql script
      >
      Trouble is I cant get "current timestamp" to work. When I click on
      import in phpmyadmin I can choose "csv" or "csv mha"
      I try csv and set
      row end to ;
      field surround to '
      field seperator to ,
      >
      The txt file for csv import contains
      '',NOW(),'infot est1';'',NOW(), 'infotest2';
      >
      It imports the data and gives me the autoincrement value but the time
      stamp is left as 0000-00-00 00:00:00
      >
      Feedback:
      INSERT INTO `all_epst`
      VALUES (
      '', 'NOW()', 'infotest1'
      )
      >
      INSERT INTO `all_epst`
      VALUES (
      '', 'NOW()', 'infotest2'
      )
      >
      I tried another txt file with
      '','','infotest 1';'','','infot est2';
      Again, it imports the data and gives me the autoincrement value but
      the time stamp is left as 0000-00-00 00:00:00
      VALUES (
      '', '', 'infotest1'
      )
      INSERT INTO `all_epst`
      VALUES (
      '', '', 'infotest2'
      )
      >
      Note that the tabel is correctly structered with "CURRENT_TIMEST AMP"
      as the default. The attribute ("ON UPDATE CURRENT_TIMESTA MP" is not
      applicable as I am adding new values, but is set anyway.)
      >
      What am I missing? How do I import with a csv text file using
      phpmyadmin?
      >
      Any help greatfully appreciated
      Garry Jones
      Sweden
      >
      You're right - phpMyAdmin isn't supported on usenet. They have their
      own forums on sourceforge.

      That's where you should be asking.

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      Working...