1

我正在尝试通过表单(帖子)更新数据库中的记录,但是当我访问全局参数变量时,由于某种原因,仅返回原始输入的第一个字符。

      $conn->beginTransaction();
      $sql = "UPDATE AS_PEOPLE SET pid=? WHERE name=?";
      $stmt = $conn->prepare($sql);

      $values = Array($_REQUEST['project'][0], $_REQUEST['person'][0]);

      $stmt->execute($values);
      $conn->commit();

      echo "Ressource allocated<br>";
      print_r($values);
4

1 回答 1

4

Your problem is here

$values = Array($_REQUEST['project'][0], $_REQUEST['person'][0]);

$_REQUEST['project'] and $_REQUEST['person'] are strings, containing values of selected option. If you tell php to get the index of 0 of a string it returns the first letter only

   $values = Array($_REQUEST['project'], $_REQUEST['person']);
于 2014-03-26T10:26:32.137 回答