title: How Do I Fix the implode error that keeps coming up
body: <p>Below is the code that I have copied as I was following a tutorial and the affected code is line 150 where it is telling me this error: Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, mysqli given in C:\xampp\htdocs\shopping cart\shop_order.php:150 Stack trace: #0 C:\xampp\htdocs\shopping cart\shop_order.php(150): implode(Array, Object(mysqli)) #1 {main} thrown in C:\xampp\htdocs\shopping cart\shop_order.php on line 150</p>
  <pre><code>&lt;?php
   /* Program name:  Shop_order.php
    * Description:   Processes order when it's been submitted.
    */
  session_start();                                                               
  include(&quot;dbinfo.inc&quot;);
  if(!isset($_SESSION['order_number']))                                          
  {
     echo &quot;No order number found&lt;br&gt;\n
     &lt;a href='shop_products.php'&gt;Continue shopping&lt;/a&gt;&quot;;
     exit();
  }
  if(@$_GET['from'] == &quot;cart&quot;)                                            
  {
     include(&quot;shop_form_shipinfo.inc&quot;);
     exit();
  }
  elseif(isset($_POST['Summary']))                                               
  {
     foreach($_POST as $field =&gt; $value)                                      
     {
  
  if ($value == &quot;&quot;)
        {
           $blanks[] = $field;
        }
        else
        {
          $good_data[$field] = strip_tags(trim($value));
        }
     }
     if(isset($blanks))
     {
        $message = &quot;The following fields are blank.
                    Please enter the required information:  &quot;;
        foreach($blanks as $value)
        {
           $message .=&quot;$value, &quot;;
        }
        extract($good_data);
        include(&quot;shop_form_shipinfo.inc&quot;);
        exit();
     }
     foreach($_POST as $field =&gt; $value)                                      
     {
       if($field != &quot;Summary&quot;)
       {
         if(preg_match(&quot;/name/i&quot;,$field))
         {
           if (!preg_match(&quot;/^[A-Za-z' -]{1,50}$/&quot;,$value))
           {
              $errors[] = &quot;$value is not a valid name.&quot;;
           }
         }
         if(preg_match(&quot;/street/i&quot;,$field)or
            preg_match(&quot;/addr/i&quot;,$field) or
            preg_match(&quot;/city/i&quot;,$field))
         {
           if(!preg_match(&quot;/^[A-Za-z0-9.,' -]{1,50}$/&quot;,$value))
           {
              $errors[] = &quot;$value is not a valid address
                            or city.&quot;;
           }
         }
         if(preg_match(&quot;/state/i&quot;,$field))
         {
           if(!preg_match(&quot;/[A-Za-z]/&quot;,$value))
           {
              $errors[] = &quot;$value is not a valid state.&quot;;
           }
         }
  
  if(preg_match(&quot;/email/i&quot;,$field))
         {
           if(!preg_match(&quot;/^.+@.+\\..+$/&quot;,$value))
           {
              $errors[]=&quot;$value is not a valid email address.&quot;;
           }
         }
         if(preg_match(&quot;/zip/i&quot;,$field))
         {
           if(!preg_match(&quot;/^[0-9]{5,5}(\-[0-9]{4,4})?$/&quot;,
                          $value))
           {
              $errors[] = &quot;$value is not a valid zipcode.&quot;;
           }
         }
         if(preg_match(&quot;/phone/i&quot;,$field))
         {
           if(!preg_match(&quot;/^[0-9)(xX -]{7,20}$/&quot;,$value))
           {
              $errors[]=&quot;$value is not a valid phone number. &quot;;
           }
         }
         if(preg_match(&quot;/cc_number/&quot;,$field))
         {
           $value = trim($value);
           $value = ereg_replace(' ','',$value);
           $value = ereg_replace('-','',$value);
           $_POST['cc_number'] = $value;
           if($_POST['cc_type'] == &quot;visa&quot;)
           {
             if(!preg_match(&quot;/^[4]{1,1}[0-9]{12,15}$/&quot;,$value))
             {
               $errors[]=&quot;$value is not a valid Visa number. &quot;;
             }
           }
           elseif($_POST['cc_type'] == &quot;mc&quot;)
           {
             if(!preg_match(&quot;/^[5]{1,1}[0-9]{15,15}$/&quot;,$value))
             {
               $errors[] = &quot;$value is not a valid
                             Mastercard number. &quot;;
             }
           }
           else
           {
             if(!preg_match(&quot;/^[3]{1,1}[0-9]{14,14}$/&quot;,$value))
             {
               $errors[] = &quot;$value is not a valid
                             American Express number. &quot;;
  
  }
           }
         }
         $$field = strip_tags(trim($value));
       }
     }
     if(@is_array($errors))
     {
        $message = &quot;&quot;;
        foreach($errors as $value)
        {
           $message .= $value.&quot; Please try again&lt;br /&gt;&quot;;
        }
        include(&quot;shop_form_shipinfo.inc&quot;);
        exit();
     }                                                                           
      /* Process data when all fields are correct */
     $cxn = mysqli_connect($host,$user,$passwd,$dbname);
     foreach($_POST as $field =&gt; $value)                                      
     {
        if($field != &quot;Summary&quot; )                 
        {
           $value = mysqli_real_escape_string($cxn,$value);
           $updates[] = &quot;$field = '$value'&quot;;
        }
     }
     $update_string = implode($updates,$cxn);                                     
     $sql_ship = &quot;UPDATE CustomerOrder SET $update_string                        
            WHERE order_number='{$_SESSION['order_number']}'&quot;;
     $result = mysqli_query($cxn,$sql_ship)
                   or die(mysqli_error($cxn));
     extract($_POST);                                                            
     include(&quot;shop_page_summary.inc&quot;);
  }
  elseif(isset($_POST['Ship']))                                                  
  {
     include(&quot;shop_form_shipinfo.inc&quot;);
  }
  elseif(isset($_POST['Final']))                                                 
  {
     switch ($_POST['Final'])                                                    
     {
        case &quot;Continue Shopping&quot;:                                                
           header(&quot;Location: shop_products.php&quot;);
           break;
        case &quot;Cancel Order&quot;:                                                     
           #include(&quot;shop_page_cancel.inc&quot;);
           unset($_SESSION['order_number']);
           session_destroy();
           exit();
           break;
  
  case &quot;Submit Order&quot;:                                                    
           $cxn =
              mysqli_connect($host,$user,$passwd,$dbname);
           $sql = &quot;UPDATE CustomerOrder SET submitted='yes'
             WHERE order_number='{$_SESSION['order_number']}'&quot;;
           $result = mysqli_query($cxn,$sql)
                  or die(&quot;Error: &quot;.mysqli_error($cxn));
           #processCCInfo();                                                     
           #sendOrder();                                                         
           #include(&quot;shop_page_accept.inc&quot;);                                     
           #email();                                                            
           session_destroy();                                                    
           break;
      }
  }
  ?&gt;
  </code></pre>
  <p>Here is the affected part of the code:</p>
  <pre><code>/* Process data when all fields are correct */
     $cxn = mysqli_connect($host,$user,$passwd,$dbname);
     foreach($_POST as $field =&gt; $value)                                      
     {
        if($field != &quot;Summary&quot; )                 
        {
           $value = mysqli_real_escape_string($cxn,$value);
           $updates[] = &quot;$field = '$value'&quot;;
        }
     }
     $update_string = implode($updates,&quot;,&quot;); /* This is the affected area this is how it is in the tutorial I was following. */                                   
     $sql_ship = &quot;UPDATE CustomerOrder SET $update_string                        
            WHERE order_number='{$_SESSION['order_number']}'&quot;;
     $result = mysqli_query($cxn,$sql_ship)
                   or die(mysqli_error($cxn));
     extract($_POST);                                                            
     include(&quot;shop_page_summary.inc&quot;);
  }
  </code></pre>
  <p>I have tried replacing &quot;,&quot; with different fields and I still got the error. the place is suppose to show the order summary.</p>