Jump to content

Multiple insert problem


MicroShaft

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

Link to comment
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--]

Link to comment
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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.