By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,722 Members | 1,904 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,722 IT Pros & Developers. It's quick & easy.

php import to table failing

P: n/a
(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(),'infotest1');
INSERT INTO all_epst VALUES ('',NOW(),'infotest2');

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(),'infotest1';'',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
'','','infotest1';'','','infotest2';
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_TIMESTAMP"
as the default. The attribute ("ON UPDATE CURRENT_TIMESTAMP" 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
Feb 24 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"GarryJones" <mo****@algonet.sewrote in message
news:52**********************************@u69g2000 hse.googlegroups.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(),'infotest1');
INSERT INTO all_epst VALUES ('',NOW(),'infotest2');

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(),'infotest1';'',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
'','','infotest1';'','','infotest2';
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_TIMESTAMP"
as the default. The attribute ("ON UPDATE CURRENT_TIMESTAMP" 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.

Feb 24 '08 #2

P: n/a
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(),'infotest1');
INSERT INTO all_epst VALUES ('',NOW(),'infotest2');

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(),'infotest1';'',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
'','','infotest1';'','','infotest2';
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_TIMESTAMP"
as the default. The attribute ("ON UPDATE CURRENT_TIMESTAMP" 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.
js*******@attglobal.net
==================

Feb 24 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.