I am stuck with this for hours, trying to fix it, but my little knowledge of php is not being enough, so I am asking for your help.
HTML
<input type="checkbox" name="type[]" value="type1">Type 1<br>
<input type="checkbox" name="type[]" value="type2">Type 2<br>
<input type="checkbox" name="type[]" value="type3">Type 3<br>
<input type="checkbox" name="type[]" value="type4">Type 4
PHP validate (separate file)
if (empty($_POST["type"])) {
$typeErr = "This field is required";
} else {
$type = array($_POST["type"]);
}
PHP
/*this is line 90*/ $type_string = implode(',', $type);
$sql = "INSERT INTO `table1`(`type`) VALUES ('$type_string')";
Error
Notice: Array to string conversion in C:\xampp\htdocs\project\example.php on line 90
It keeps telling me I am converting an array to string when I use implode, I have no idea what I am doing wrong, I just have several checkboxes, and the selected ones go to an array, then I implode that array to a string to be able to send it to the mysql database...
It is probably a stupid mistake, but I am fairly new to php and mysql, so... can anyone help me?
I wrote $type_string to $typestring, but the problem remains, the notice still happens...
$type_string != $typestring