connot通过引用

时间:2017-04-25 13:16:36

标签: php mysqli

我一直不能通过引用传递参数2,虽然表单中的名称,变量类型都可以。 我见过其他人的情况,看起来很合理,但我在这里找不到错误。



 $sid = $_POST['staff_id'];
 $sname = $_POST['staff_name'];
 $sgender = $_POST['gender'];
 $sdob = $_POST['staff_dob'];
 $sbranch = $_POST['branch'];
 $stell = $_POST['tel_no'];
 $position = $_POST['position'];
 $salary =$_POST['salary'];
 $login = $_POST['staff_login'];
 $password = $_POST['staff_password'];
}
else{     
 $stmt = $mysqli->prepare("INSERT INTO
              staff (staff_id, staff_name, gender, staff_dob, branch, tell_no, position, salary, staff_login, staff_password) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
 $stmt->bind_param('ssssssiiss', '$sid', '$sname', '$sgender', '$sdob', '$sbranch', '$stell', '$position', '$salary', '$login', '$password');
  




这是我的html表单:

      <form method="post" action="">

      <input type="text" name="staff_id" placeholder="your given ID">
      <input type="text" name="staff_name" placeholder="Full Name"/>
      <label class="formlabel">Your gender:</label>
      <input type="text" name="gender" placeholder="male/female">
      <label class="formlabel"><b>Date of Birth:</b></label>
      <input type="date" name="staff_dob">
      <input type="text" name="branch" placeholder="Your branch ID">
      <input type="tel" name="tel_no" placeholder="your telephone number">
      <label class="formlabel"><b>Your position</b></label>
      <select name="position">
        <option value="1"> Asisstant</option>
        <option value="2"> Supervisor</option>
        <option value="3"> Manager</option>
      </select>
      <input type="number" name="salary" placeholder="your salary ammount">
      <input type="text" name="staff_login" placeholder="Make your new login">
     <input type="password" name="staff_password" placeholder="Enter your new password">
      <button type="submit" name="btn-register" value="submit">Register</button>
  </form>

2 个答案:

答案 0 :(得分:0)

删除&#39; &#39;围绕所有变量。它的含义是你不能传入一个引用变量,它需要是一个带有bind_param的值

if rand_float < rar:
    action = rand.randint(0, num_actions - 1)
else:
    action = np.argmax(Q[s_prime_as_index])

为什么要引入$ _POST变量,但在mysqli之前还有一个else?

答案 1 :(得分:-1)

您必须了解字符串变量之间的区别。

变量不是字符串。并且应该写成没有引号。