50 points for MYSQL Help

btfog

New Member
Messages
118
Reaction score
2
Points
0
First person to get fix this gets 50 points

On a page that I'm trying I get these 2 warnings

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/****/public_html/Copy of logindemo/processes.php on line 144

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/****/public_html/Copy of logindemo/processes.php on line 145

Line 144 & 145 look like this

$login_check = mysql_num_rows($sql);
$row=mysql_fetch_assoc($sql);




 

btfog

New Member
Messages
118
Reaction score
2
Points
0
Does This Work I Put lines 144 & 145 in bold

include '../Copy of logindemo/include/db.php';
$username = $_POST['username'];
$passwordbef = $_POST['password'];
$rember = $_POST['rember'];

if((!$username) || (!$passwordbef)){
$alert = "<br>You didnt put all you login details in.<br />";
include '../Copy of logindemo/index.php';
exit();
}

$password = md5($passwordbef);

$sql = mysql_query("SELECT * FROM ".DBTBLE." WHERE username='$username' AND password='$password'");
$login_check = mysql_num_rows($sql_username AND password);
$row=mysql_fetch_assoc($sql_);


$session_username = $row['username'];
$session_first_name = $row['first_name'];
$session_last_name = $row['last_name'];
$session_email_address = $row['email_address'];
$session_info = $row['info'];
$session_user_level = $row['user_level'];
$session_password = $row['password'];

if ($rember == "yes") {

$cookie_name = "".CKIEUS."";
$cookie_value = $session_username;
$cookie_expire = time()+60*60*24*30;

setcookie($cookie_name,$cookie_value,$cookie_expire,"/");

$cookie_name = "".CKIEPS."";
$cookie_value = $session_password;
$cookie_expire = time()+60*60*24*30;

setcookie($cookie_name,$cookie_value,$cookie_expire,"/");

}
if($login_check > 0){

$_SESSION['first_name'] = $session_first_name;
$_SESSION['last_name'] = $session_last_name;
$_SESSION['email_address'] = $session_email_address;
$_SESSION['username'] = $session_username;
$_SESSION['info'] = $session_info;
$_SESSION['user_level'] = $session_user_level;
$_SESSION['password'] = $session_password;

header("Location: main.php");

}

else {
$alert = "<br>Username or Password incorrect<br />";
include '../Copy of logindemo/index.php';
}
 

Tariqul Islam

New Member
Messages
182
Reaction score
0
Points
0
When connecting you should follow the following script:

$sql = "SELECT * FROM " . DBTBLE . " WHERE username='" . $username . "' AND password='" . $password . "'";
$result = mysql_query($sql);
$login_check = mysql_num_rows($result);
$row=mysql_fetch_assoc($result);


I think your problem is solved.
 

satheesh

New Member
Messages
883
Reaction score
0
Points
0
$sql = mysql_query("SELECT * FROM ".DBTBLE." WHERE username='$username' AND password='$password'");
$result = mysql_query($sql);


First run your Query.
 

btfog

New Member
Messages
118
Reaction score
2
Points
0
satheesh got it right. thanks for your help everyone. i'm paying you now satheesh
 
Top