mysql database not updating when there is a space in php variable

I am trying to get my mysql database to update a value in a column when a checkbox is checked/unchecked. This works for 1 word variable, but somehow refuses when the checkbox that is checked has 2 words (in other words, has a space in the string).

The list of checkboxes in the form is taken from the database which holds the name used for the checkbox name field and the actual text displayed.

<input type="checkbox" class="form-check-input filter_check" value="<?= $row['buttons_allowed_activated']; ?>" name="<?= $row['Service']; ?>" id="labels" <?php if ($activate_status == 1) echo 'checked="checked"'; ?>><?= $row['Service'];?> 

This works flawlesly and there are no issues when it comes to values like “My Value” taken from the database Service column.

From there the edit document takes over when the form is posted (as usual) and there I check on every Service (by Service name as it comes from the database in the checkbox fields) if the checkbox was checked or not:

$checkboxes_array = array();
$unset_value = array();

if (isset($_POST['Service1'])) {
    $checkboxes_array[] = 'Service1';
} else {
    $unset_values[] = 'Service1';
}
        
if (isset($_POST['My Service2'])) {
    $checkboxes_array[] = 'My Service2';
} else {
    $unset_values[] = 'My Service2';
}

if (isset($_POST['Service3'])) {
    $checkboxes_array[] = 'Service3';
} else {
    $unset_values[] = 'Service3';
}

I then loop over them as the idea of this form is to enable/disable Services on the homepage. This is done by looping over both the $unset_values array as the $checkboxes_array to know which ones should have the enabled tag (1) set in the database or which ones should be set to disabled (0).

foreach ($checkboxes_array as &$checkbox){
    $button_set_results = mysqli_query($conn, "SELECT * FROM buttons_allowed INNER JOIN buttons ON buttons_allowed.buttons_allowed_button_id=buttons.button_id WHERE (buttons_allowed_userid) IN ('".$userId."') AND (Service) IN ('".$checkbox."') ");
    while ($rows = mysqli_fetch_array($button_set_results)){
        $button_set_service = $rows['Service'];
            
        $update = mysqli_query($conn, "UPDATE buttons_allowed INNER JOIN buttons ON buttons_allowed.buttons_allowed_button_id=buttons.button_id set buttons_allowed_activated = 1 where Service = '".$button_set_service."' and buttons_allowed_userid = '".$userId."' ");
    }
}       
        
foreach( $unset_values as &$unset_value ){
    $button_unset_results = mysqli_query($conn, "SELECT * FROM buttons_allowed INNER JOIN buttons ON buttons_allowed.buttons_allowed_button_id=buttons.button_id WHERE (buttons_allowed_userid) IN ('".$userId."') AND (Service) IN ('".$unset_value."') ");
    while ($rows = mysqli_fetch_array($button_unset_results)){
        $button_unset_service = $rows['Service'];
        
        $update = mysqli_query($conn, "UPDATE buttons_allowed INNER JOIN buttons ON buttons_allowed.buttons_allowed_button_id=buttons.button_id set buttons_allowed_activated = 0 where Service = '".$button_unset_service."' and buttons_allowed_userid = '".$userId."' ");
    }
} 

From what I am seeing, it just doesn’t make sense that I am unable to set the disabled tag (buttons_allowed_activated) to 0 for the strings with a space in them while I am unable to set them as enabled. The code is exactly the same except for the array used and the value set for the buttons_allowed_activated column.

What am I missing here or what am I doing wrong?

I checked if the values in the arrays are correct and in line with the Service column, which they are.

I tried the call in the database itself and that works normally and actually sets the value to 1 as it should:

UPDATE buttons_allowed INNER JOIN buttons ON buttons_allowed.buttons_allowed_button_id=buttons.button_id set buttons_allowed_activated = 1 where Service = 'My Service2' and buttons_allowed_userid = '{user id for testing purposes}'

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật