Jump to content


Photo

Multiple insert problem


  • Please log in to reply
3 replies to this topic

#1 MicroShaft

MicroShaft
  • Members
  • Pip
  • Newbie
  • 4 posts
  • LocationStoke on Trent (I know but someone has to live there)

Posted 02 November 2005 - 09:38 PM

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

#2 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 02 November 2005 - 10:53 PM

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--]
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#3 MicroShaft

MicroShaft
  • Members
  • Pip
  • Newbie
  • 4 posts
  • LocationStoke on Trent (I know but someone has to live there)

Posted 02 November 2005 - 11:09 PM

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--]

View Post


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


#4 Cook

Cook
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts
  • LocationSingapore

Posted 03 November 2005 - 12:46 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users