0

Hi im trying to convert a multidimensional array into a database but none of the values are being added in. Currently ive set up a foreach loop in order to access the different levels of the array and bind paramaters with those vatriables. I get the error "Method call uses 5 parameters, but mehtod signature uses 3 " But i dont think that is the main problem with my code. MY database structure is a only a single table with 4 columns (Day, Hour, Subject 'id')

foreach ($timetable as $day => $subTimetable) {
foreach ($subTimetable as $hour => $subject) {
    $conn = mysqli_connect("localhost", "root", "");
    $db = mysqli_select_db($conn, "test");
    $stmt =mysqli_prepare($conn,"INSERT INTO `timetable` (`Day`, `hour`, `subject`) VALUES (?, ?, ?);");
    mysqli_stmt_bind_param($stmt, 'sss', $Day, $hour, $subject);

    mysqli_stmt_execute($stmt);
}
Ravi Matani
  • 804
  • 1
  • 8
  • 21
  • Currently, there is no evidence that your problem is mysqli related. However, your question is off topic, as you don't actually know what your problem is. Narrow your question to a certain problem and then re-ask. First of all, try to see whether your loops are iterated at least once – Your Common Sense Jan 23 '17 at 10:03
  • On a side note, you should move connect, prepare and bind outside the loop. – Your Common Sense Jan 23 '17 at 10:04
  • ok ive moved everything and added the line "mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);" try to and help debug the error and will reask when i have a more specific problem – Adam Anderson Jan 23 '17 at 10:11

0 Answers0