wordpress select multiple options and illegal string offset ‘timeslot’ [closed]

You are getting illegal string offset 'timeslot' because $time is not an array, it is an item in array $timeslots. You have already retrieved the values submitted using $timeslots = $_POST['timeslot'];

Your code also contains other typing mistakes.
Here is corrected code:

<form method="POST">
   <select name="timeslot[]" multiple="multiple" size = 4 required>
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
   </select>
   <input type="submit" name="submit"/>
</form>

<?php
if(isset($_POST['submit'])){
    global $wpdb;
    $booking_timeslots = $wpdb->prefix . 'booking_timeslots';   
    $timeslots = $_POST['timeslot'];
    // you can use print_r() here 
    print_r( $timeslots );  // to see what is submitted from form

    foreach ($timeslots as $time) {
          echo $time;
    }
}
?>

I hope this helps.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)