I am a beginner to PHP, currently working on a long survey. Below is the code which is causing issues, the data from the checked boxes are added to a database:
$_q4 = (isset($_GET['check_q4']) ? $_GET['check_q4'] : null);
$q4 = '';
foreach($_q4 as $a4) {
$q4 .= $a4;}
<div class="group v-group">
<label><input type="checkbox" name="check_q4[]" value="1"> Checkbox 1</label>
<label><input type="checkbox" name="check_q4[]" value="2"> Checkbox 2</label>
<label><input type="checkbox" name="check_q4[]" value="3"> Checkbox 3</label>
</div>
Error:
Warning: Invalid argument supplied for foreach() in C:\inetpub\wwwroot\submit_form.php on line 79 Failed to run query: SQLSTATE[22001]:
Many thanks for you help.