我尝试过已经在主题中写过的内容,但它没有奏效 我得到了SQLSTATE [HY093]: 这是我的代码;
<?php
include '
black/netting/islem.php';
$user = new USER();
if($user->is_loggedin()!="")
{
$user->redirect('home.php');
}
?>
islem.php ;
<?php
function tckimlik($tcno) {
$olmaz=array('11111111110','22222222220','33333333330','44444444440','55555555550','66666666660','7777777770','88888888880','99999999990');
if($tckimlik[0]==0 or !ctype_digit($tckimlik) or strlen($tckimlik)!=11){ return false; }
else{
for($a=0;$a<9;$a=$a+2){ $ilkt=$ilkt+$tckimlik[$a]; }
for($a=1;$a<9;$a=$a+2){ $sont=$sont+$tckimlik[$a]; }
for($a=0;$a<10;$a=$a+1){ $tumt=$tumt+$tckimlik[$a]; }
if(($ilkt*7-$sont)%10!=$tckimlik[9] or $tumt%10!=$tckimlik[10]){ return false; }
else{
foreach($olmaz as $olurmu){ if($tckimlik==$olurmu){ return false; } }
return true;
}
}
}
if(isset($_POST['tcsorgula']))
{
$tcno = strip_tags($_POST['tcno']);
$tel_no = strip_tags($_POST['tel_no']);
$mail = strip_tags($_POST['mail']);
$forum_name = strip_tags($_POST['forum_name']);
$uye_sifre = strip_tags($_POST['uye_sifre']);
$type = strip_tags($_POST['type']);
$first_name = strip_tags($_POST['first_name']);
$last_name = strip_tags($_POST['last_name']);
$gender = strip_tags($_POST['gender']);
$user_birth = strip_tags($_POST['user_birth']);
if(!filter_var($mail, FILTER_VALIDATE_EMAIL)) {
$error[] = 'Lütfen geçerli bir e-mail adresi giriniz!';
}
else if(strlen($uye_sifre) < 6){
$error[] = "Şifreniz en az 6 karakterden oluşmalıdır";
}
else if($uye_sifre!=$sifre_tekrar) {
$error[] = "Lütfen şifrenizi tekrar doğru giriniz";
}
else if (isset($_POST['tcsorgula'])) {
if(tckimlik($_POST['tcno'])){
} else {
echo "tc kimlik no sorunlu";
}
}
}
else {
try
{
$stmt = $user->runQuery("SELECT user_tcno, user_tel, user_email, user_fname FROM users WHERE user_tcno=:tcno OR user_tel=:tel_no OR user_email=:mail OR user_fname=:forum_name");
$stmt->execute(array(':uname'=>$tcno, ':umail'=>$mail));
$row=$stmt->fetch(PDO::FETCH_ASSOC);
if($row['user_fname']==$forum_name) {
$error[] = "Üzgünüz forum kullanıcı adı alındı !";
}
else if($row['user_tel']==$tel_no) {
$error[] = "Bu telefon numarası kayfı bulunmaktadır lütfen farklı bir telefon numarası giriniz...";
}
else if($row['user_email']==$mail) {
$error[] = "Bu e-mail kayfı bulunmaktadır lütfen farklı bir e-mail adresi giriniz...";
}
else if($row['user_tcno']==$tcno) {
$error[] = "Bu T.C kimlik numarası kaydı bulunmaktadır lütfen farklı bir T.C kimlik numarası giriniz...";
}
else
{
if($user->register($first_name,$last_name,$tcno,$tel_no,$mail,$uye_sifre,$gender,$user_birth,$forum_name,$type)){
$user->redirect('kayit.php?joined');
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
?>
<?php
require_once('dbconfig.php');
class USER
{
private $conn;
public function __construct()
{
$database = new Database();
$db = $database->dbConnection();
$this->conn = $db;
}
public function runQuery($sql)
{
$stmt = $this->conn->prepare($sql);
return $stmt;
}
public function register($first_name,$last_name,$tcno,$tel_no,$mail,$uye_sifre,$gender,$user_birth,$forum_name,$type)
{
try
{
$new_password = password_hash($uye_sifre, PASSWORD_DEFAULT);
$stmt = $this->conn->prepare("INSERT INTO users(user_name,user_sirname,user_tcno,user_tel,user_email,user_pass,user_gender,user_birthd,user_fname,user_type)
VALUES(:user_name, :user_sirname, :user_tcno, :user_tel, :user_email, :new_password, :user_gender, :user_birthd, :forum_name, :user_type)");
$stmt->bindparam(":user_name", $first_name);
$stmt->bindparam(":user_sirname", $last_name);
$stmt->bindparam(":user_tcno", $tcno);
$stmt->bindparam(":user_tel", $tel_no);
$stmt->bindparam(":user_email", $mail);
$stmt->bindparam(":user_fname", $forum_name);
$stmt->bindparam(":user_gender", $gender);
$stmt->bindparam(":user_birthd", $user_birth);
$stmt->bindparam(":user_type", $type);
$stmt->bindparam(":new_password", $new_password);
$stmt->execute();
return $stmt;
}
catch (PDOException $e)
{
echo $e->getMessage();
}
} ?>
然后我得到了
SQLSTATE [HY093]:参数号无效:绑定变量数与令牌数不匹配
答案 0 :(得分:0)
显示错误,因为您的参数未正确序列化&amp;您的参数编号无效。您当前的参数是:
首先检查一下:
$stmt = $user->runQuery("SELECT user_tcno, user_tel, user_email, user_fname FROM users WHERE user_tcno=:tcno OR user_tel=:tel_no OR user_email=:mail OR user_fname=:forum_name");
$stmt->execute(array(':uname'=>$tcno, ':umail'=>$mail));
以这种方式更改:
$stmt = $user->runQuery("SELECT user_tcno, user_tel, user_email, user_fname FROM users WHERE user_tcno=:tcno OR user_tel=:tel_no OR user_email=:mail OR user_fname=:forum_name");
$stmt->execute(array(':tcno'=>$tcno, ':tel_no'=> $telNo, ':mail' => $mail, ':forum_name' => $forumName));
现在在这里:
$stmt->bindparam(":user_name", $first_name);
$stmt->bindparam(":user_sirname", $last_name);
$stmt->bindparam(":user_tcno", $tcno);
$stmt->bindparam(":user_tel", $tel_no);
$stmt->bindparam(":user_email", $mail);
$stmt->bindparam(":user_fname", $forum_name);
$stmt->bindparam(":user_gender", $gender);
$stmt->bindparam(":user_birthd", $user_birth);
$stmt->bindparam(":user_type", $type);
$stmt->bindparam(":new_password", $new_password);
您必须按照以下方式更改它们:
$stmt->bindparam(":user_name", $first_name);
$stmt->bindparam(":user_sirname", $last_name);
$stmt->bindparam(":user_tcno", $tcno);
$stmt->bindparam(":user_tel", $tel_no);
$stmt->bindparam(":user_email", $mail);
$stmt->bindparam(":new_password", $new_password);
$stmt->bindparam(":user_fname", $forum_name);
$stmt->bindparam(":user_gender", $gender);
$stmt->bindparam(":user_birthd", $user_birth);
$stmt->bindparam(":user_type", $type);
现在希望这个错误会消失。