0

hey
i seem to get this everytime i run this file within my login script
Warning: mysql_result() expects parameter 1 to be resource, boolean given in C:\wamp\www\Isis\login.php on line 16
can anyone help me please?
heres my code

<?php


    $username = $_POST['username'];
    $password = $_POST['password'];
    $login = $_GET['login'];
    
    setcookie("username", "$username", time()+86400);

    if ($login=='yes') {
        $con = mysql_connect("localhost","root","");
        mysql_select_db("obsosuser");
        
        $get = mysql_query("SELECT count(id) FROM obsosuser WHERE username='$username' and password='$password'");
        
        $result = mysql_result($get, 0);
        if ($result!=1){
            echo "Invalid Login!";
            
        } else
            echo "Login Successful! Welcome back ".$_COOKIE['username']." Sir/Maddam." ;
            $_SESSION ['username'] = $username;
    }

?>

Thanks

Edited by jamesyrawr: n/a

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by vibhaJ
0
<?php


    $username = $_POST['username'];
    $password = $_POST['password'];
    $login = $_GET['login'];
    
    setcookie("username", "$username", time()+86400);

    if ($login=='yes') {
        $con = mysql_connect("localhost","root","");
        mysql_select_db("obsosuser");
        
        $sql = "SELECT count(id) FROM obsosuser WHERE username='$username' and password='$password'";
        $query = mysql_query($sql);   
		$result = mysql_num_rows($query);  

        if ( $result == 1 ) 
		{
			echo "Login Successful! Welcome back ".$_COOKIE['username']." Sir/Maddam." ;
            $_SESSION ['username'] = $username;
		}
		else
		{
			echo "Invalid Login!";
		}
    }
?>

Try this code.

Edited by vibhaJ: n/a

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.