***** problem====can't insert into my table but when i ver_dump it it shows all record needed to be insert====
Here is my sample code.

for ($col = 0; $col <= $highestColumnIndex; $col++) { 
//assigning all data to one variable 
$allcolrowdata =$columnNames = mysqli_real_escape_string($connect, $worksheet->getCellByColumnAndRow($col, $row)->getValue()); 
   //echo $allcolrowdata.'<br>';
   $allcolrowdataexplode=explode(",",$allcolrowdata);
   var_dump( $allcolrowdataexplode).'<br>';
  foreach($allcolrowdataexplode as $key => $inserted){

//echo $inserted;
$query_insert ="INSERT INTO tem_treg2 (title,surname,first_name,middle_name,gender,dob,marital_status,occupation,phone_number,company_name,registration_type,registered_by,tax_id,office_address,office_city,temp_reg,workplace_category,active,monthly_gross,nhf,nhis,nsitf,basic_salary,grade,designation,pension,gratuity) 
VALUES ('','$inserted','','','','','','$textfile_occupation','','$institution','','$UserLogin','','','','','','','','','','','','','','','')
";
//var_dump($query_insert);
//('','$values1','$inserted','','','','','$textfile_occupation','','$institution','','$UserLogin','','','','','','','','','','','','','','','')

}
                }

Recommended Answers

All 3 Replies

Where you define variables $textfile_occupation, $institution, $UserLogin ?
Where you execute $query_insert ?

thanks for your fast repond
here is where i define them

$institution=$_SESSION['Company'];
$UserLogin=$_SESSION['UserLogin'];
$textfile_surname = $_POST['surname'];
$textfile_occupation = $_POST['occupation2'];
$textfile_occupation1 = $_POST['occupation'];
$textfile__monthlygross = $_POST['monthly_gross'];

 mysqli_query($connect, $query_insert);  echo mysqli_error($connect);
  1. mysqli_query() should be inside for (line 15)
  2. Use filter_input() to sanitize user input variables
  3. Bind variables after prepare
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.