猿问

将多个复选框值存储到 php mysqli 数据库中

抱歉,如果我要问的是一个愚蠢的问题,但我一直在阅读并尝试可用的代码,但它们都不起作用。这是我了解存储多个复选框值的链接

  1. 如何插入多个复选框值

  2. 在数据库中添加多个复选框值

  3. Mysqli-PHP 将多个复选框值存储到一条记录中

我有一个带有多个复选框的表单,我需要将值存储到数据库中。我现在的问题是它一直弹出这个错误

解析错误:语法错误,意外的“$chk”(T_VARIABLE),期待“)”

下面是我的代码

notification_form.php

<div class="form-group row">

  <label class="col-md-2 col-form-label">Potential Escalation: </label>

  <div class="col-md-5">

    <input type="checkbox" id="potential_escalation[]" value="Under control with available resources. No potential of escalation" />&nbsp;<text>Under control with available resources. No potential of escalation.</text>

  </div>

  <div class="col-md-5">

    <input type="checkbox" id="potential_escalation[]" value="May requires additional resources (e.g. authorities, contractors, mutual aid groups)." />&nbsp;<text>May requires additional resources (e.g. authorities, contractors, mutual aid groups).</text>

  </div>

</div>


<div class="form-group row">

  <label class="col-md-2 col-form-label"></label>

  <div class="col-md-5">

    <input type="checkbox" id="potential_escalation[]" value="Authorities may take over command and control" />&nbsp;<text>Authorities may take over command and control.</text>

  </div>

  <div class="col-md-5">

    <input type="checkbox" id="potential_escalation[]" value="May triggers significants authorities/ public community/ media interest." />&nbsp;<text>May triggers significants authorities/ public community/ media interest.</text>

  </div>


</div>


慕田峪4524236
浏览 90回答 1
1回答

白衣染霜花

$checkbox1 = mysqli_real_escape_string($conn, $_POST['potential_escalation'] <-- 你错过了结束圆圈);
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答