note 113331 deleted from mysqli-stmt.store-result by peehaa
| From: | peehaa@php.net | Date: | Sat, 28 Sep 2013 16:03:46 +0000 |
| Subject: | note 113331 deleted from mysqli-stmt.store-result by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196403@lists.php.net to get a copy of this message | ||
Note Submitter: ccherese at yahoo dot com
----
Can someone help me with my code, i've already stored the results before calling num_rows but
still it would give me a 0 answer. For testing purposes, i've tried to echo store_result to see
if something is being store, it gives out 1 so it's fine but when i tried to echo num_rows, the
answer is 0...why?
can someone help me?
$con = mysqli_connect("localhost", "root", "", "pamsignup")
or die('error in connection'.mysqli_connect_error());
error_reporting(E_ALL);
if(isset($_POST['login']))
{
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$con = mysqli_connect("localhost", "root", "",
"pamsignup");
$sql = "SELECT 1 FROM registries WHERE username=? AND password=?";
$stmt = mysqli_prepare($con, $sql);
mysqli_stmt_bind_param($stmt, 'ss', $_POST['username'],
$_POST['password']);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
if(mysqli_stmt_num_rows($stmt) == 1)
{
header('Location: PAM-home.php');
mysqli_stmt_free_result($stmt);
}
else
{
//header('Location: PAM-login.php');
echo 'Wrong Password';
}
mysqli_stmt_close($stmt);
}