Jump to content

Archived

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

MicroShaft

Multiple insert problem

Recommended Posts

Im trying to insert 1080 records into mysql.

 

I extract the raw data from a table. place into a array. which is then split into an array (each element containing a record)

 

I run a FOR loop to insert into the db.

 

The problem: Only 855 records seem to get inserted : with no errors

 


$thedata_rawL1=explode("\n",$thedata_raw);

foreach ($thedata_rawL1 as $v) 
{

$sql_insertloop="INSERT INTO ori_data (LOAD_ID,THEDATA) Values('$new_LOAD_ID','$v')";

$change_rs = mysql_db_query("originsuk",$sql_insertloop,$connect);
}

 

Can any one shed some light why i can only enter 855 when i have over 1000. I dont get no error messages.

 

im using mysql 4 with php 4

Share this post


Link to post
Share on other sites

there were probably some duplicate keys that you aren't aware of. are the two tables different in structure?

 

also, you wouldn't need to use a loop to copy tables, all you need is the INSERT INTO ... SELECT query

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']INSERT[/span] INTO ori_data (LOAD_ID,THEDATA) [span style=\'color:blue;font-weight:bold\']SELECT[/span] field1,field2 FROM table2 [!--sql2--][/div][!--sql3--]

Share this post


Link to post
Share on other sites
there were probably some duplicate keys that you aren't aware of. are the two tables different in structure?

 

also, you wouldn't need to use a loop to copy tables, all you need is the INSERT INTO ... SELECT query

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']INSERT[/span] INTO ori_data (LOAD_ID,THEDATA) [span style=\'color:blue;font-weight:bold\']SELECT[/span] field1,field2 FROM table2 [!--sql2--][/div][!--sql3--]

314183[/snapback]

 

Okay, i just done some investigation. The raw data was originally posted via text area to the db. the data was pasted into a text area. for some reason even though a 1000 rows were pasted into the text area only 855 got inserted into the db which is a memo field.

 

so the multiple insert was right.

 

Now any ideas why the text area only inserted 855 rows into the memo field

 

Share this post


Link to post
Share on other sites

Must have to do with the maximum length of text a textarea can store. These things are not limitless... ;)

Share this post


Link to post
Share on other sites

×

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.