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...

Recommended Answers

All 3 Replies

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

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); 
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.