php - Warning: implode(): Invalid arguments passed -


i have gone through ton of invalid arguments passed messages on forum , sorry have not found example helps situation.

as can see code below generous of rasclatt, have several field names including 9 files uploaded server while rest of fields submitted database.

when attempt run code, get, "warning: implode(): invalid arguments passed in..." on line 94 - start of insert statement.

an important point note not files can uploaded @ 1 time during insert.

users can elect upload files, can elect upload 1 file during insert iteration.

any idea how resolve this?

<?php    error_reporting(e_error | e_warning | e_parse);   include("../connections/connect.php");  // function used sanitize code against sql injection attack. function ms_escape_string($data) {         if ( !isset($data) or empty($data) ) return '';         if ( is_numeric($data) ) return $data;          $non_displayables = array(             '/%0[0-8bcef]/',            // url encoded 00-08, 11, 12, 14, 15             '/%1[0-9a-f]/',             // url encoded 16-31             '/[\x00-\x08]/',            // 00-08             '/\x0b/',                   // 11             '/\x0c/',                   // 12             '/[\x0e-\x1f]/'             // 14-31         );         foreach ( $non_displayables $regex )             $data = preg_replace( $regex, '', $data );         $data = str_replace("'", "''", $data );         return $data;     }      // may want add document root     $target = $_server['document_root']."/uploads";     // filtering files incase there empty uploads     // need have proper file input name (item)     $_files['item']['tmp_name'] =   array_filter($_files['item']['tmp_name']);     $_files['item']['name'] =   array_filter($_files['item']['name']);     $_files['item']['type'] =   array_filter($_files['item']['type']);     $_files['item']['size'] =   array_filter($_files['item']['size']);       foreach($_files['item']['name'] $i => $value ) {             $file_name              =   $_files['item']['name'][$i];             $file_size              =   $_files['item']['size'][$i];             $file_tmp               =   $_files['item']['tmp_name'][$i];             $file_type              =   $_files['item']['type'][$i];              $biddate                =   ms_escape_string($_post['txtbiddate']);             $duedate                =   ms_escape_string($_post['txtduedate']);             $duetime                =   ms_escape_string($_post['txtduetime']);             $bidtitle               =   ms_escape_string($_post['bidtitle']);             $bidid                  =   ms_escape_string($_post['bidid']);             $desc                   =   ms_escape_string($_post['description']);             $dept                   =   ms_escape_string($_post['department']);             $bidcontact             =   ms_escape_string($_post['bidcontact']);             $contactemail           =   ms_escape_string($_post['contactemail']);             $contactphone           =   ms_escape_string($_post['contactphone']);             $numbids                =   ms_escape_string($_post['numofbids']);             $awarddate              =   ms_escape_string($_post['txtawarddate']);             $awardrecip1            =   ms_escape_string($_post['awardrecip']);             $bidtype                =   ms_escape_string($_post['bidtype']);             $lastupdate             =   ms_escape_string($_post['txtlastupdate']);             $notes                  =   ms_escape_string($_post['notes']);             $status                 =   ms_escape_string($_post['status']);              $sqlarr['values'][$i]   =   "'".ms_escape_string($_files['item']['name'][$i])."'";             $sqlarr['columns'][$i]  =   "addend".$i;             $sqlarr['columns']  =   "signinsheet";             $sqlarr['columns']  =   "tabsheet";             $sqlarr['columns']  =   "bidfile";             // @ point notifying user.             // have no code prevent limitation.             if ($file_type!="application/pdf" || $file_type!="image/gif" || $file_type!="image/jpeg")                  $echo =    'you can upload pdfs, jpegs or gif files.<br>';             // far, notification, haven't             // done limitation             if($file_size >  (8 * 1024 * 1024))                 $echo='file size must less 8 mb';              // makes folder if not made.             if(!is_dir($target))                 mkdir($target,0755,true);              //writes files server             if(move_uploaded_file($_files['item']['tmp_name'][$i], $target."/".$file_name)) {                 //if ok                 echo "the file ". $file_name. " has been uploaded directory , records saved database";             }             else {              //gives , error if not             echo "sorry, there problem uploading file.";             }         } if(isset($sqlarr['columns'])) {     $sql="insert bids (biddate,duedate,duetime,bidtitle,bidid,description,,'".implode("','",$sqlarr['columns'])."',department,xcontract,contactemail,contactphone,numofbids,awarddate,awardrecip1,bidtype,lastupdate,notes,bidstatus)               values ('$biddate', '$duedate','$duetime',$bidtitle','$bidid','$desc',".implode(",",$sqlarr['values']).", '$dept','$bidcontact','$contactemail','$contactphone','$numbids','$awarddate','$awardrecip1','$bidtype','$lastupdate','$notes',$status')" ;     $objquery = sqlsrv_query($conn, $sql);     sqlsrv_close($conn); } ?> 

one problem:

 $sqlarr['columns']  =   "signinsheet";  $sqlarr['columns']  =   "tabsheet";  $sqlarr['columns']  =   "bidfile"; 

is overwriting value, not creating array, want:

 $sqlarr['columns'][]  =   "signinsheet";  $sqlarr['columns'][] =   "tabsheet";  $sqlarr['columns'][]  =   "bidfile"; 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

ios - Possible to get UIButton sizeThatFits to work? -