php - invalid object or resource mysqli_stmt -


i want run multiple mysql queries( not concurrently). using prepared statements doing so. gist of code :

    <?php    if(isset($_get['username'])&&isset($_get['activationid'])){  require_once("../database/db_connect.php");  $stmt= $mysqli->stmt_init(); $stmt->prepare("select username users username= ? , activationid= ?"); $username=$_get['username']; $activationid=$_get['activationid']; $stmt->bind_param("ss",$username,$activationid); $stmt->execute(); $row=$stmt->get_result()->fetch_array(mysqli_assoc);  if(!strcmp($row['username'],$username)){     echo 'you registered successfully';    $stmt->prepare("update users set active=yes username = ?"); $stmt->bind_param("s",$username); $stmt->execute();        } }  ?> 

and db_connect.php :

<?php       define('dbhost','localhost'); define('dbuser','root'); define('dbpass','password'); define('dbname','reminder');      $mysqli= new mysqli(dbhost,dbuser,dbpass,dbname) ;     if($mysqli->connect_error) {       echo $mysqli->mysqli_connect_error();      } else { echo "connected successfully"; }     ?> 

this gives me error :

warning: mysqli_stmt::bind_param(): number of variables doesn't match number of parameters in prepared statement in

can tell me doing wrong ?

please chenge code below , check:-

//$stmt= $mysqli->stmt_init(); comment line $stmt = $mysqli->prepare("select username users username= ? , activationid= ?") or die( $mysqli->error); $username=$_get['username']; $activationid=$_get['activationid']; $stmt->bind_param("ss",$userid,$activationid); $stmt->execute(); 

and second 1 same :-

$stmt = $mysqli->prepare("update users set active=yes username = ?") or die($mysqli->error); $stmt->bind_param("s",$username); $stmt->execute(); 

note:- please take care variables defined , set. thanks.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -