PHP Array to string to mysql - empty record

96 Views Asked by At

I am on point where I have to usk on forum.

So, I have an array that is my return from join table sql query. i am displaying it correctly without the problem.

but some of those values I want to put in different table of mysql database. $array = joint_table(); $array_value = array['key'];

I can echo array_value and it's displaying correctly, also checked variable type and it returns STRING.

however when I am inserting it into the table, it's empty cell. I am inserting other stuff like date() and such and that is inserted correctly. So my sql query works fine, besides I am using same query in other places without problem.

Only values I have from that array are not inserting, but still can echo them.

    <?php
  $page_title = 'Complete Task';
  require_once('includes/load.php');
  // Checkin What level user has permission to view this page
  page_require_level(2);
  $task = join_task_table((int)$_GET['id']);

?>

<?php
 if(isset($_POST['complete_task'])){
   $area = $task['area'] ;
   $jig = $task['jig'];   
   $desc = $task['description'];
   $freq = $task['freq']; 
   $date = make_date();
   $user = current_user();
   $user_done = remove_junk(ucfirst($user['name'])); 
   $comment   = remove_junk($db->escape($_POST['comment']));
   if(empty($errors)){
      $sql  = "INSERT INTO tpm_history (area_name,jig_name,description,frequency,date_done,done_by_user,comment)";
      $sql .= " VALUES ('{$area}','{$jig}','{$desc}','{$freq}','{$date}','{$user_done}','{$comment}')";
       $result = $db->query($sql);
               if($result && $db->affected_rows() === 1){
                 $session->msg('s',"Job Completed");
                 redirect('home.php', false);
               } else {
                 $session->msg('d',' Sorry failed to complete the task!');
                 redirect('task_complete.php?id='.$task['id'], false);
               }

   } else{
     $session->msg("d", $errors);
     redirect('task_complete.php?id='.$task['id'],false);
   }

 }

?>

I am lost. Help.

0

There are 0 best solutions below