scott.stephan Posted July 8, 2009 Share Posted July 8, 2009 This one is driving me bonkers. I have a little script that takes 3 groups of stuff and moves them from their current tables into "Archive" tables: $queryall="SELECT * FROM new_batch WHERE po_num='$curr_po_num'"; $result=mysql_query($queryall) or die(mysql_error()); while($row=mysql_fetch_array($result)){ $delivery_num=$row[deliverynum]; $swapbatch="INSERT INTO archive_batch SELECT * FROM new_batch WHERE po_num='$curr_po_num'"; $deletebatch="DELETE FROM new_batch WHERE po_num='$curr_po_num'"; // echo "PO NUM SWAPPED: '$row[po_num]'"; $swapbatchresult = @mysql_query($swapbatch); $deletebatchresult = @mysql_query($deletebatch); // echo "RECORD SWAPPED 1 line"; } $queryall_bol="SELECT * FROM bol_new WHERE po_num='$curr_po_num'"; $result_bol=mysql_query($queryall_bol) or die(mysql_error()); while($row_bol=mysql_fetch_array($result_bol)){ $swapbatch="INSERT INTO bol_archive SELECT * FROM bol_new WHERE po_num='$curr_po_num'"; //WON'T ARCHIVE $deletebatch="DELETE FROM bol_new WHERE po_num='$curr_po_num'"; //WILL DELETE // echo "PO NUM SWAPPED: '$row_bol[po_num]'"; $swapbatchresult = @mysql_query($swapbatch); $deletebatchresult = @mysql_query($deletebatch); } $queryall_lots="SELECT * FROM lots_new WHERE lot_rec='$curr_po_num'"; $result_lots=mysql_query($queryall_lots) or die(mysql_error()); while($row_lot=mysql_fetch_array($result_lots)){ $swapbatch="INSERT INTO lots_archive SELECT * FROM lots_new WHERE lot_rec='$curr_po_num'"; $deletebatch="DELETE FROM lots_new WHERE lot_rec='$curr_po_num'"; //echo "PO NUM SWAPPED: '$row[po_num]'"; $swapbatchresult = @mysql_query($swapbatch); $deletebatchresult = @mysql_query($deletebatch); //echo "RECORD SWAPPED 1 line"; } It alll runs fine. Except for one line: $swapbatch="INSERT INTO bol_archive SELECT * FROM bol_new WHERE po_num='$curr_po_num'"; //WON'T ARCHIVE It won't work. It's formatted exactly the same. I have checked it up and down 70 times (Yes, the table names are correct ). I can't see the problem. Thoughts? Link to comment https://forums.phpfreaks.com/topic/165244-solved-sql-error-not-moving-stuff-between-tables/ Share on other sites More sharing options...
JJ2K Posted July 8, 2009 Share Posted July 8, 2009 Well what's the error use or die(mysql_error()); for the problematic part Link to comment https://forums.phpfreaks.com/topic/165244-solved-sql-error-not-moving-stuff-between-tables/#findComment-871467 Share on other sites More sharing options...
scott.stephan Posted July 8, 2009 Author Share Posted July 8, 2009 Stupid stupid stupid- I forgot that I'd added a field to bol_new and not to bol_archive. Ugh. Solved. Always make sure your tables have equal columns. Link to comment https://forums.phpfreaks.com/topic/165244-solved-sql-error-not-moving-stuff-between-tables/#findComment-871497 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.