php - SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1 -
can me? when try register new admin, system show me error: sqlstate[21s01] got following code similar question didn't solve question
this class.admin.php, contain function register new admin
public function registro_admin($auser, $aemail, $apass, $adep, $aname, $alast, $agender, $amatricula){ try{ $new_password = password_hash($apass, password_bcrypt); $stmt = $this->db->prepare("insert admin(admin_user, admin_email, admin_password, admin_departamento, admin_name, admin_lastname, admin_matricula) values(:auser, :aemail, :apass, :adep, :aname, :alast, :agender, :amatricula)"); $stmt->bindparam(":auser", $auser); $stmt->bindparam(":aemail", $aemail); $stmt->bindparam(":apass", $apass); $stmt->bindparam(":adep", $adep); $stmt->bindparam(":aname", $aname); $stmt->bindparam(":alast", $alast); $stmt->bindparam(":agender", $agender); $stmt->bindparam(":amatricula", $amatricula); #$stmt->bindparam(":apic", $apic); $stmt->execute(); return $stmt; }catch(pdoexception $e){ echo $e->getmessage(); } }
this admin-register.php contain html form , php code validation
else if(strlen($apass) < 6){ echo '<script>alert("password must contain more 6 characters");</script>'; }else{ try{ $stmt = $db_con->prepare("select admin_user, admin_email admin admin_user=:auser or admin_email=:aemail"); $stmt->execute(array(':auser'=>$auser, ':aemail'=>$aemail)); $row=$stmt->fetch(pdo::fetch_assoc); if($row['admin_user'] == $auser){ echo '<script>alert("lo sentimos, el usuario ya existe");</script>'; } else if($row['admin_email'] == $aemail){ echo '<script>alert("lo sentimos, el correo ya existe");</script>'; }else{ if($admin->registro_admin($auser, $aemail, $apass, $adep, $aname, $alast, $agender, $amatricula)){ echo '<script>alert("administrador agregado con Éxito");</script>'; } } }catch(pdoexception $e){ echo $e->getmessage(); } }
please :(
you have 7 columns defined in insert into
. need include gender column there.
so include admin_gender
under admin_lastname
Comments
Post a Comment