Jump to content

[SOLVED] Insert Data from Text File


ainoy31

Recommended Posts

I am reading data from a text file and then inserting it into a mysql table. 

 

Here is the code:

$query = "INSERT INTO user_mail_list(userid, mail_date) VALUES (";

$fh = fopen("userid.txt", "r");

while(!feof($fh))
{
$data = fgets($fh, 4096);	

$sql = $query . $data . ', 2009-06-30)';
mysql_query($sql);
}

 

It inserts into the table fine but the my mail date column has 0000:00:00 values rather than the 2009-06-30.  I have echoed the query as well and it looks good.

 

INSERT INTO user_mail_list(userid, mail_date) VALUES (5 , 2009-06-30)

INSERT INTO user_mail_list(userid, mail_date) VALUES (184 , 2009-06-30)

INSERT INTO user_mail_list(userid, mail_date) VALUES (469 , 2009-06-30)

 

I am missing something stupid here.

 

Thanks.

 

AM

 

Link to comment
https://forums.phpfreaks.com/topic/164977-solved-insert-data-from-text-file/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.