Hi guys, I having the same problem also, and I'm using 000webhost also. Below is my code and I can actually insert the data into database but I wonder why the error message is keep showing and very annoying .... :-\ Can anyone help me to identify the problem ?
<?php
for ($a = 1; $a <= $number ; $a++) {
if ((${subject.$a}[1] == "Beta" ) || (${subject.$a}[1] == "beta" )){
$two_hours_lec = (${subject.$a}[2])/2;
$one_hour_lec = (${subject.$a}[2])%2;
$beta_array_code = ${subject.$a}[0];
$beta_lec = mysql_query("SELECT * FROM slot WHERE subject = '$beta_array_code' AND type = 'lecture' ");
while ($beta_result = mysql_fetch_array($beta_lec)) {
$beta_section = $beta_result[section];
// for 2 hours class
$check_same_day = array(); // to empty the array
for ($bs = 1 ; $bs <= $two_hours_lec ; $bs ++ ){
$check_hour2 = 100; // to make sure after one loop, the content in while loop will be executed
$count_array = count($beta_slots);
$check_first_hour = array(0,0);
$check_second_hour = array(0,0);
// check whether the element in array[random number + 1] is continuous to the element in array[random number] with the while loop below
while ((($check_hour2 - $check_hour1) != 1) || ($check_day1 != $check_day2)) {
$check_again = false;
$rand = rand(0, $count_array -1);
$rand2 = $rand +1;
$first_hour = $beta_slots[$rand];
$second_hour = $beta_slots[$rand2];
$check_first_hour = preg_split('#(?<=[a-z])(?=\d)#i', $first_hour); //split the alphabet and number into array where first element is alphabet and 2nd is number
$check_second_hour = preg_split('#(?<=[a-z])(?=\d)#i', $second_hour);
$check_hour1 = $check_first_hour[1];
$check_hour2 = $check_second_hour[1];
$check_day1 = $check_first_hour[0];
$check_day2 = $check_second_hour[0];
$key = array_search($check_day1 , $check_same_day);
if ($key !== false) {
$check_hour2 = 100; // again to make sure the while loop will be executed
}
$first_lec_hour = $check_hour1 * 100;
$second_lec_hour = $check_hour2 * 100;
}
array_push($check_same_day, $check_day1); // Insert the alphabet into the array to prevent the later hours of same section fall in same day
$check_day = find_day($first_hour); // mon - fri
$insert_first = mysql_query("INSERT INTO ".$beta_array_code." (section,type,day,start) VALUES ('$beta_section','lecture','$check_day','$first_lec_hour')");
$insert_second = mysql_query("INSERT INTO ".$beta_array_code." (section,type,day,start) VALUES ('$beta_section','lecture','$check_day','$second_lec_hour')");
if (isset($insert_first) && isset($insert_second)) {array_splice($beta_slots, $rand , 2);}
}
// if there is one hour class
if ($one_hour_lec != "") {
while (!isset($insert_one)) {
$count_array1 = count($beta_slots);
$rand1 = rand(0, $count_array1 -1);
$one_hour = $beta_slots[$rand1];
$check_one_hour = preg_split('#(?<=[a-z])(?=\d)#i', $one_hour);
$one_hour_check = $check_one_hour[0];
$key1 = array_search($one_hour_check , $check_same_day);
if ($key1 !== false) { continue; }
$check_day_1 = find_day($one_hour);
$one_lec_hour = $check_one_hour[1] *100;
$insert_one = mysql_query("INSERT INTO ".$beta_array_code." (section,type,day,start) VALUES ('$beta_section','lecture','$check_day_1','$one_lec_hour')");
}
unset($insert_one);
}
}
}
}
?>