title: How do I turn an Array into String?
body: <p>I'm trying to add my data from a form into my database. But when I click the submit button, it shows me this error:</p>
  
  <pre><code>Notice: Array to string conversion in C:\xampp\htdocs\stock\php_action\createAppointment.php on line 16
  
  Notice: Array to string conversion in C:\xampp\htdocs\stock\php_action\createAppointment.php on line 16
  {"success":true,"messages":"Successfully Added"}
  </code></pre>
  
  <p>I've searched and landed on this site. It told me to use implode but I do not know where to place it and when I looked at the function it's for echoing an array into a string but I want to add the data to the database instead of echoing it.</p>
  
  <p>Here is my code for the <strong>line 16</strong> thing:</p>
  
  <pre><code>&lt;?php   
  require_once 'core.php';
  
  $valid['success'] = array('success' =&gt; false, 'messages' =&gt; array(), 'appointment_id' =&gt; '');
  // print_r($valid);
  if($_POST) {    
  
    $appointmentDate          = date('Y-m-d', strtotime($_POST['appointmentDate']));  
    $patientName              = $_POST['patientName'];
    $physicianName            = $_POST['physicianName'];
    $description              = $_POST['description'];
  
  
  
      $sql = "INSERT INTO appointment (appointment_date, patient_name, physician_name, description) VALUES ('$appointmentDate', '$patientName', '$physicianName', '$description')";
      }
      if($connect-&gt;query($sql) === TRUE) {
                      $valid['success'] = true;
                      $valid['messages'] = "Successfully Added";  
                  } else {
                      $valid['success'] = false;
                      $valid['messages'] = "Error while adding the members";
                  }
  
  // /if $_POST
  // echo json_encode($valid);
      $connect-&gt;close();
  
      echo json_encode($valid);
  
  // /if $_POST
  </code></pre>
  
  <p><strong>line 16</strong> is this line:</p>
  
  <pre><code> $sql = "INSERT INTO appointment (appointment_date, patient_name, physician_name, description) VALUES ('$appointmentDate', '$patientName', '$physicianName', '$description')";
  </code></pre>
  
  <p>edit:</p>
  
  <p>I've checked my DB and it adds values (although i added empty data except for the top one which has 's' in the description) but physician name and patient name are the ones that are arrays.</p>
  
  <p>This is my code for physician name (same with patient name):</p>
  
  <pre><code>&lt;?php
      $physicianSql = "SELECT * FROM physician WHERE physician_active = 1 AND physician_status = 1";
      $physicianData = $connect-&gt;query($physicianSql);
  
      while($row = $physicianData-&gt;fetch_array()) {                                           
          $selected = "";
          if($row['physician_id'] == $orderItemData['physician_id']) {
              $selected = "selected";
          } else {
              $selected = "";
          }
  
          echo "&lt;option value='".$row['physician_id']."' id='changePhysician".$row['physician_id']."' ".$selected." &gt;".$row['physician_name']."&lt;/option&gt;";
      } // /while 
  
  ?&gt;
  </code></pre>
  
  <p>here is the screenshot of the DB: 
  <a href="https://i.imgur.com/PYbUn1G.png" rel="nofollow noreferrer">https://i.imgur.com/PYbUn1G.png</a></p>