0

after I store the data into an array, and then inserting the data in the database. the data does not appear in the database despite being successfully ran.

Upload.php

<?php
require  "dbh.inc.php";
$image = $_FILES['image']['name'];
$image_tmp = $_FILES['image']['tmp_name'];
    // $ake = array();
if (isset($_FILES['image'])) {

    for($i=0;$i<9;$i++){
    $target = "../images/".basename($image[$i]);

    if (move_uploaded_file( $image_tmp[$i], $target)) {

         $msg ="<br>Image Uploaded successfully<br>";
         echo $image[$i];
         echo $msg;

        }else {
            $msg= "<br>There was a problem Uploading image<br>";
            echo $msg;
            $bolen =false;
         }
    }
        if ($bolen) {

        $sql= "INSERT INTO documents1 (exam_result,reg_slip,status_letter,attendance,photograph,matric,offer_letter,payment) 
        VALUES ('$image[0]','$image[1]','$image[2]','$image[3]','$image[4]','$image[5]','$image[6]','$image[7]','$image[8]');";
        mysqli_query($conn,$sql);
    }

} else{

    echo "You did not sumbit";
}

sql doucments1 table

--
-- Table structure for table `documents1`
--

CREATE TABLE `documents1` (
  `passport` tinytext,
  `exam_result` tinytext,
  `reg_slip` tinytext,
  `status_letter` tinytext,
  `attendance` tinytext,
  `photograph` tinytext,
  `matric` tinytext,
  `offer_letter` tinytext,
  `payment` tinytext
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
COMMIT;


there are no columns, and no errors appeared.

1 Answer 1

2

You have 9 values to write your database table but only specified 8 columns where your data should be inserted. Your db server just doesn't know how to do that.

On top of that you won't be able to see any errors from your db server if you don't set any error handling.

Some good reading about mysqli error handling

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.