PHP: Error: SQLSTATE [HY093]: Invalid parameter number: parameter was not defined

1

I'm doing a Login method but I can not solve this error, I would really appreciate your help

<?php
  try {
    $base = new PDO("mysql:host = localhost; dbname = estimasoft", "root", "");
    $base->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $sql = "SELECT * FROM usuario WHERE nombre = :nombre AND contraseña = :contraseña";
    $resultado = $base->prepare($sql);
    $nombre = htmlentities(addslashes($_POST["nombre"]));
    //echo $nombre;
    $contraseña = htmlentities(addslashes($_POST["contraseña"]));
    $resultado->bindValue(':nombre', $nombre);
    $resultado->bindValue(':contraseña', $contraseña);
    $resultado->execute();
    $numeroRegistro = $resultado->rowCount();
    if($numeroRegistro == 1){
        echo "adelante";
    }else{
      header("location: ../index1.php");
    }
} catch (Exception $e) {
    die("Error: ".$e->getMessage());
}
?>

and the form is this:

<form class="container col-lg-4 col-lg-offset-4" action="sistema/comprueba_login.php" method="post">
    <div class="form-group">
         <label for="user">Usuario:</label>
         <input class="form-control" type="text" name="nombre" value="" id="user" placeholder="Usuario">
    </div>
    <div class="form-group">
         <label for="password">Contraseña:</label>
         <input class="form-control" type="password" name="contraseña" value="" id="password" placeholder="Contraseña">
   </div>
   <div class="row">
        <input class="btn btn-default col-lg-4 col-lg-offset-4" type="submit" name="name" value="Ingresar">
   </div>
</form>
    
asked by Joseph Leon 16.05.2016 в 18:59
source

1 answer

2

Based on the comments the error

  

SQLSTATE [HY093]: Invalid parameter number: parameter was not defined

It may be by the name of the password column, it is possible that you are not recognizing the letter ñ in ': password'.

and the error

  

SQLSTATE [3D000]: Invalid catalog name: 1046 No database selected

is due to the name of the database, check if the name of the database in your PDO connection string is well written

    
answered by 16.05.2016 / 20:52
source