Jump to content

[SOLVED] SQL Error- Not moving stuff between Tables.


scott.stephan

Recommended Posts

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?

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.