php - Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement in C:\User..\ on 148 -
hello i'm inserting new column collegename, branch, , gender it's giving me error...
warning: mysqli_stmt::bind_param(): number of variables doesn't match number of parameters in prepared statement in c:\users\raj\phpstormprojects\usercake\models \class.newuser.php on line 148
what's mean?
actually inserting new column database college
, branch
, year
, , gender
goes when register myself it's shows message registration submitted shows error message wells as?? i'm supposed wrong please help?
here source code:
<?php class user { public $user_active = 0; private $clean_email; public $status = false; private $clean_password; private $username; private $displayname; public $sql_failure = false; public $mail_failure = false; public $email_taken = false; public $username_taken = false; public $displayname_taken = false; public $activation_token = 0; public $success = null; function __construct($user,$display,$pass,$email) { //used display $this->displayname = $display; //sanitize $this->clean_email = sanitize($email); $this->clean_password = trim($pass); $this->username = sanitize($user); if(usernameexists($this->username)) { $this->username_taken = true; } else if(displaynameexists($this->displayname)) { $this->displayname_taken = true; } else if(emailexists($this->clean_email)) { $this->email_taken = true; } else { //no problems have been found. $this->status = true; } } public function usercakeadduser() { global $mysqli,$emailactivation,$websiteurl,$db_table_prefix; //prevent function being called if there construction errors if($this->status) { //construct secure hash plain text password $secure_pass = generatehash($this->clean_password); //construct unique activation token $this->activation_token = generateactivationtoken(); //do need send out activation email? if($emailactivation == "true") { //user must activate account first $this->user_active = 0; $mail = new usercakemail(); //build activation message $activation_message = lang("account_activation_message",array($websiteurl,$this->activation_token)); //define more if want build larger structures $hooks = array( "searchstrs" => array("#activation-message","#activation-key","#username#"), "subjectstrs" => array($activation_message,$this->activation_token,$this->displayname) ); /* build template - optional, can use sendmail function instead pass message. */ if(!$mail->newtemplatemsg("new-registration.txt",$hooks)) { $this->mail_failure = true; } else { //send mail. specify users email here , subject. //sendmail can have third parementer message if not wish build template. if(!$mail->sendmail($this->clean_email,"new user")) { $this->mail_failure = true; } } $this->success = lang("account_registration_complete_type2"); } else { //instant account activation $this->user_active = 1; $this->success = lang("account_registration_complete_type1"); } if(!$this->mail_failure) { //insert user database providing no errors have been found. $stmt = $mysqli->prepare("insert ".$db_table_prefix."users ( user_name, display_name, password, email, college, branch, year, gender, activation_token, last_activation_request, lost_password_request, active, title, sign_up_stamp, last_sign_in_stamp ) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, '".time()."', '0', ?, 'new member', '".time()."', '0' )"); $stmt->bind_param("sssssi", $this->username, $this->displayname, $secure_pass, $this->clean_email, $this->activation_token, $this->user_active); $stmt->execute(); $inserted_id = $mysqli->insert_id; $stmt->close(); //insert default permission matches table $stmt = $mysqli->prepare("insert ".$db_table_prefix."user_permission_matches ( user_id, permission_id ) values ( ?, '1' )"); $stmt->bind_param("s", $inserted_id); $stmt->execute(); $stmt->close(); } } } } ?>
you have 10 ? in prepare statement passed 6 variables on $stmt->bind_param. must pass same variables have in statement. bind must this:
$stmt->bind_param('isisississ', $int1, $str1, $int2, $str2, $int3, $str3, $str4, $int4, $str5, $str6);
Comments
Post a Comment