Hallo luitjes,

Ik ben een module aan het maken voor een band waar ik in speel. Het is de bedoeling dat de manager optredens kan toevoegen, en dat deze dan direct wordt gemaild naar naar de leden en ook direct aan de database wordt toegevoegd. Het mail gedeelte werkt perfect, alleen op het database gedeelte krijg ik steeds de volgende foutmelding:

SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens


Ik heb alles al nagelopen maar ik kan niks vinden. Hieronder mijn code's. Hopelijk kunnen jullie iets vinden! :-)


HTML

<form class="form-horizontal" method="post" action>
<fieldset>

<div class="form-group">
  <label class="col-md-4 control-label" for="titel">Titel:</label>  
  <div class="col-md-4">
  <input id="titel" name="titel" type="text" class="form-control input-md" required>
    
  </div>
</div>

<div class="form-group">
  <label class="col-md-4 control-label" for="plaats">Plaats:</label>  
  <div class="col-md-4">
  <input id="plaats" name="plaats" type="text" class="form-control input-md" required>
    
  </div>
</div>

<div class="form-group">
  <label class="col-md-4 control-label" for="datum">Datum:</label>  
  <div class="col-md-4">
  <input id="datum" name="datum" type="date" class="form-control input-md" required>
    
  </div>
</div>

<div class="form-group">
  <label class="col-md-4 control-label" for="begintijd">Begintijd:</label>  
  <div class="col-md-4">
  <input id="begintijd" name="begintijd" type="time" class="form-control input-md" required>
    
  </div>
</div>

<div class="form-group">
  <label class="col-md-4 control-label" for="eindtijd">Eindtijd:</label>  
  <div class="col-md-4">
  <input id="eindtijd" name="eindtijd" type="time" class="form-control input-md" required>
    
  </div>
</div>

<div class="form-group">
  <label class="col-md-4 control-label" for="categorie">Categorie:</label>
  <div class="col-md-4">
    <select id="categorie" name="categorie" class="form-control">
      <option value="Blaaskapel">Blaaskapel</option>
      <option value="Pietenband">Pietenband</option>
      <option value="Kerstband">Kerstband</option>
      <option value="Algemeen">Algemeen</option>
    </select>
  </div>
</div>

<!-- E-mail ja/nee wordt niet opgenomen in database -->
<div class="form-group">
  <label class="col-md-4 control-label" for="email">Mail versturen:</label>
  <div class="col-md-4">
    <select id="email" name="email" class="form-control">
      <option value="yes">Ja</option>
      <option value="no">Nee</option>
    </select>
  </div>
</div>

<!-- Button -->
<div class="form-group">
  <label class="col-md-4 control-label" for="submit"></label>
  <div class="col-md-4">
    <button id="submit" name="toevoegen" class="btn btn-primary">Toevoegen</button>
  </div>
</div>

</fieldset>
</form>




PHP[/b] (E-mail script even weggelaten):
<?php require_once 'db_config.php';

if(isset($_POST["toevoegen"])) {
  try {
    $sQuery = "INSERT INTO agenda (titel, plaats, datum, begintijd, eindtijd, categorie)
              VALUES (:titel, :plaats, :datum, :begintijd, :eindtijd, categorie)";
    $oStmt = $db->prepare($sQuery);
    $oStmt->bindParam(':titel', $_POST['titel'], PDO::PARAM_STR);
    $oStmt->bindParam(':plaats', $_POST['plaats'], PDO::PARAM_STR);
    $oStmt->bindParam(':datum', $_POST['datum'], PDO::PARAM_STR);
    $oStmt->bindParam(':begintijd', $_POST['begintijd'], PDO::PARAM_STR);
    $oStmt->bindParam(':eindtijd', $_POST['eindtijd'], PDO::PARAM_STR);
    $oStmt->bindParam(':categorie', $_POST['categorie'], PDO::PARAM_STR);
    $oStmt->execute();
    echo '<br><div class="alert alert-success" role="alert">Optreden is toegevoegd!</div>';
  }
  
  catch(PDOException $e) {
    $sMsg = '<p>
            Regelnummer: '.$e->getLine().'<br />
            Bestand: '.$e->getFile().'<br />
            Foutmelding: '.$e->getMessage().'
            </p>';
    trigger_error($sMsg);
  }
}

?>



Database structuur

Bij categorie in je VALUES mist een dubbele punt.
- Ariën - op 21/08/2016 23:22:44

Bij categorie in je VALUES mist een dubbele punt.


Je bent een held! Dat ik dat zelf niet gezien heb :O

P.S. Volgende keer gebruik ik de code tag! ;-)

Reageren