PHP Prepared Statement Problems -


slowly getting used php prepared statements, still error

"warning: mysqli_stmt::bind_result(): number of bind variables doesn't match number of fields in prepared statement in c:\users\pc\documents\xampp\htdocs\login.php on line 20".

 <?php   $mysqli = new mysqli('localhost', 'c3337015', 'c3337015', 'members');  if (mysqli_connect_errno()) {     printf("connect failed: %s\n", mysqli_connect_error());     exit();     }   if(isset($_get['loginemail'])){   session_start();      $stmt = $mysqli->prepare("select email members email=? ,  password=? limit 1");     $email = $_get['loginemail'];     $password = $_get['loginpassword'];     $password = sha1($password);     $stmt->bind_param('ss', $email, $password);     $stmt->execute();     $stmt->bind_result($email, $password);     $stmt->store_result();     if($stmt->num_rows == 1)  //to check if row exists         {             while($stmt->fetch()) //fetching contents of row                {$_session['logged'] = 1;                $_session['email'] = $email;                header('location: index.php');                exit();                }         }         else {             echo "wrong username or password!";         }         $stmt->close();     }     else      {        echo "something went wrong";     } $mysqli->close(); ?> 

$stmt->bind_result($email, $password); 

you binding 2 variables, asking one: select email members.

i'd suggest using different variables bind_result, , bind_param both work on references.

$stmt->bind_result($useremail); 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -