<? require('../libs/connection.php'); $skins = R::find('skins'); ?> <form action="<? $_SERVER['PHP_SELF'] ?>" method="POST"> <p><input type="text" name="name" placeholder="Название кейса"></p> <? $ch = array(); $i = 0; foreach ($skins as $skin) { if($skin['rare'] == "Ширпотреб") { echo "<input type='checkbox' name="$ch[$i]">" . $skin['gun'] . ' | ' . $skin['name'] . '<br>'; $i++; } elseif($skin['rare'] == "Промышленное качество") { echo "<input type='checkbox' name="$ch[$i]">" . '<font color="0099ff">' . $skin['gun'] . ' | ' . $skin['name'] . '</font> <br>'; $i++; } elseif($skin['rare'] == "Армейское качество") { echo "<input type='checkbox' name="$ch[$i]">" . '<font color="0033cc">' . $skin['gun'] . ' | ' . $skin['name'] . '</font> <br>'; $i++; } elseif($skin['rare'] == "Запрещенное") { echo "<input type='checkbox' name="$ch[$i]">" . '<font color="9900cc">' . $skin['gun'] . ' | ' . $skin['name'] . '</font><br>'; $i++; } elseif($skin['rare'] == "Засекреченое") { echo "<input type='checkbox' name="$ch[$i]">" . '<font color="ff00ff">' . $skin['gun'] . ' | ' . $skin['name'] . '</font> <br>'; $i++; } elseif($skin['rare'] == "Тайное") { echo "<input type='checkbox' name="$ch[$i]">" . '<font color="ff0000">' .$skin['gun'] . ' | ' . $skin['name'] . '</font> <br>'; $i++; } } if(isset($_POST['create'])) { $case = R::dispense('cases'); $case->name = $_POST['name']; #$case->slot1 = $checkbox[''] } ?> <p><input type="submit" name="create" value="Создать кейс"></p> </form> 

Gives an error message

Parse error: syntax error, unexpected '$ ch' (T_VARIABLE), expecting ',' or ';' in C: \ OSPanel \ domains \ open-case.ru \ admin \ create-case.php on line 17

  • not $ ch [$ i], just ch [] as the name of the input. - Kirill Korushkin

1 answer 1

The string concatenation is incorrect. Replace name="$ch[$i]" with name=" . $ch[$i] . "