0

i've problem with login, if login always appear error
1.Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in....
2.Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in....

coding php:

<?php
include ("config/koneksi.php");
include ("config/library.php");
$pass = md5($_POST['password']);

$login = mysql_query("SELECT * FROM user WHERE id_user='$_POST[username]' AND sesi='$pass'");
$found = mysql_num_rows($login);                /////error
$r = mysql_fetch_array($login);                 /////error

if ($r){
  session_start();
  session_register("username");
  session_register("sesi");
  session_register("role");

  $_SESSION[username] = $r[id_user];
  $_SESSION[sesi] = $r[sesi];
  $_SESSION[role]= $r[role];
  header ('location:home.php');
}
else{
  //echo "<link href=../config/adminstyle.css rel=stylesheet type=text/css>";
  echo "<center>login failed! username & password not right<br>
        <a href=index.htm><b>ULANGI LAGI</b></a></center>";
}


?>

please solution...

4
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by Bachu
0

I am guessing you have a database connection and table selection somewhere in one of the includes?

0

Try this

$pass = md5($_POST['password']);
$id_user= $_POST[username];

$login = mysql_query("SELECT * FROM user WHERE id_user='$id_user' AND sesi='$pass'");
$found = mysql_num_rows($login); 
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.