我想创建唯一的用户 UUID [关闭]

问题描述 投票:0回答:1
<!DOCTYPE html>
<html lang="fr">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Creation affiche de présentation</title>
  <link rel="stylesheet" href="stylenew.css">
  <link rel="stylesheet" href="affiche.css">
</head>

<body>
  <div class="navbar">
    <ul>
      <li id="title"><a href="index.php">copry</a></li>
      <div class="ul_right_navbar">
        <?php
        if (isset($_COOKIE['nom'])) {
          ?>
          <li class="btn" onclick="location.href=`logout.php`">Se déconnecter</li>
          <?php
        } else {
          header('LOCATION:register.php');
          ?>
          <?php
        }
        ?>
        <svg xmlns="http://www.w3.org/2000/svg" class="icon_account" width="24" height="24" viewBox="0 0 24 24"
          stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
          <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
          <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path>
          <path d="M12 10m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"></path>
          <path d="M6.168 18.849a4 4 0 0 1 3.832 -2.849h4a4 4 0 0 1 3.834 2.855"></path>
        </svg>
        <div class="popup_user_info">
          <ul>
          </ul>
        </div>
    </ul>
  </div>
  <h1 id="slogan">Création du <span>livret d'accueil</span></h1>
  <form method="post" class="form">
    <div class="put_title">
      <label for="nom_immeuble">Nom Immeuble(e)</label>
      <input class="input_form" type="text" name="nom_immeuble" id="nom_immeuble" maxlength="20"
        placeholder="L'arbre blanc" required>
    </div>
    <div class="put_title">
      <label for="nom_assistant">Nom assistant(e)</label>
      <input class="input_form" type="text" name="nom_assistant" id="nom_assistant" maxlength="20" placeholder="David"
        required>
    </div>
    <div class="put_title">
      <label for="nom_comptable">Prénom contable</label>
      <input class="input_form" type="text" name="nom_comptable" id="nom_comptable" maxlength="20" placeholder="Jeanne"
        required>
    </div>
    <div class="put_title">
      <label for="Ascenceur">Ascenseur(s)</label>
      <input class="input_form" type="number" name="Ascenceur" id="Ascenceur" maxlength="20" placeholder="0">
    </div>
    <div class="put_title">
      <label for="Plombier">Plombier(s)</label>
      <input class="input_form" type="text" name="Plombier" id="Plombier" maxlength="20" placeholder="Christophe">
    </div>
    <div class="put_title">
      <label for="Electriciens">Electricien(s)</label>
      <input class="input_form" type="text" name="Electriciens" id="Electriciens" maxlength="20" placeholder="Antoine">
    </div>
    <div class="put_title">
      <label for="VMC">VMC</label>
      <input class="input_form" type="text" name="VMC" id="VMC" maxlength="20" placeholder="Cuisine">
    </div>
    <input id="continuer" name="formsend" type="submit"></input>
  </form>
  <?php
  if (isset($_POST['formsend'])) {
    extract($_POST);
    if (!empty($nom_immeuble) && !empty($nom_assistant) && !empty($nom_comptable)) {
      include 'database.php';
        $q = $db->prepare("INSERT INTO affiche(immeuble, assistant, comptable, Ascenseur, Plombier, Electricien, VMC) VALUES(:nom_immeuble, :nom_assistant, :nom_comptable, :Ascenceur, :Plombier, :Electriciens, :VMC)");
        $q->execute([
          'immeuble' => $nom_immeuble,
          'assistant' => $nom_assistant,
          'comptable' => $nom_comptable,
          'Ascenseur' => $Ascenceur,
          'Plombier' => $Plombier,
          'Electricien' => $Electriciens,
          'VMC' => $VMC
        ]);
      }
    }
  ?>
</body>

</html>

Voici les erreurs que j'ai: ( !) 致命错误:未捕获的 PDOException:SQLSTATE[HY093]:参数编号无效:绑定变量的数量与第 89 行 E:\wamp64\www\Airbnb ffiche_immeuble.php 中的标记数量不匹配 ( !) PDOException: SQLSTATE[HY093]: 参数编号无效:绑定变量的数量与第 89 行 E:\wamp64\www\Airbnb ffiche_immeuble.php 中的标记数量不匹配 调用栈

时间记忆功能位置

1 0.0003 368448 {main}( ) ... ffiche_immeuble.php:0 2 0.0138 417824 execute( $params = ['immeuble' => 'Maxence', 'assistant' => 'Maxence', 'comptable' => 'Maxence', 'Ascenseur' => '654', 'Plombier' => 'Maxence', 'Electricien' => 'Maxence'] ) ... ffiche_immeuble.php:89

J'essaye d'envoyer les données à une base de données php my admin mais j'ai des messages d'erreurs en retour je ne comprends pas 谢谢你的助手!

php forms unique uuid fatal-error
1个回答
0
投票

您需要确保 SQL 中使用的占位符名称与提供给

execute
方法的占位符名称匹配。

$q = $db->prepare("INSERT INTO affiche
( immeuble, assistant, comptable, Ascenseur, Plombier, Electricien, VMC ) 
  VALUES
( :nom_immeuble, :nom_assistant, :nom_comptable, :Ascenceur, :Plombier, :Electriciens, :VMC )");

$q->execute([
  ':nom_immeuble'   => $nom_immeuble,
  ':nom_assistant'  => $nom_assistant,
  ':nom_comptable'  => $nom_comptable,
  ':Ascenceur'      => $Ascenceur,
  ':Plombier'       => $Plombier,
  ':Electricien'    => $Electriciens,
  ':VMC'            => $VMC
]);

可能建议对占位符和变量使用所有

lowercase
~mySQL将忽略大小写但PHP不会将
$Var
$var
相同....

© www.soinside.com 2019 - 2024. All rights reserved.