working forever trying to resolve my script to extract the middle five characters from column "part_no" and insert the data into the "core" column (varchar). The format is always "000-00000-00".
I run this script as a part of my whole script to create a new record.
The script has no errors, but does not insert into cartons_current.
Very frustrated.
Any help would be appreciated.
The record is created but the core column is blank.

 <?
 $host     = "XXXXXXX";
 $username = "XXXXXXX";
 $password = "XXXXXXX";
 $db_name  = "XXXXXXX";
 $tbl_name = "cartons_current";
 mysql_connect("$host", "$username", "$password") or die("cannot connect");
 mysql_select_db("$db_name") or die("cannot select DB");
 date_default_timezone_set('America/Los_Angeles');
 $date = date("m/d/y g:i A");
 $order = "INSERT INTO cartons_current (orig_time, type, part_no, description, artwork, min, max, qty)
        VALUES
        ('$date','$_POST[type]', '$_POST[part_no]', '$_POST[description]',       '$_POST[artwork]', '$_POST[min]', '$_POST[max]', '$_POST[qty]')";
 $result = mysql_query($order);
 $query2 = "select part_no from cartons_current";
 $sel = mysql_query($query2);
 while($row = mysql_fetch_row($sel)) {
 $core_digits = explode('-',$row[0]);
 $core =$core_digits[1];
 $query3 = "insert  into cartons_current(core) values('$core')";
 $sel2 = mysql_query($query3);
 }
 if ($result) {
 $part_no = $_REQUEST['part_no'] ;
 header("location: inv_fc_new_success.php?part_no=" . urlencode($part_no));
 }
 else {
  header("location: inv_fc_new_fail.php");
 }
 ?>
 
     
    