Can't login to my own forum, that sucks

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Toxicous8
    New Member
    • Oct 2015
    • 57

    Can't login to my own forum, that sucks

    I'm unable to login? plz help

    Code:
     
    session_start();
    include_once ('dbconnect.php');
    
    
    if(isset($_POST['log'])) {
    	$dbselect = mysql_query("USE codb");
    	$uname = mysql_real_escape_string($_POST['username']);
    	$upass = mysql_real_escape_string($_POST['pass']);
    	$sql = mysql_query("SELECT * FROM users WHERE username=".$uname." AND password=".$upass." LIMIT 1");
    	$res = mysql_query($sql);
    	
    	
    	if(mysql_num_rows($res) == 1) {
    		$row = mysql_fetch_assoc($res);
    		$_SESSION['user'] = $row['user_id'];
    		header("Location: speak.php");
    	}else{
    		$error = error_reporting(E_ALL^E_WARNING);
    		echo "<script>alert('Wrong details!');</script>";
    	}
    	
    }



    It displays
    Code:
     
    Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\log.php on line 14
  • RonB
    Recognized Expert Contributor
    • Jun 2009
    • 589

    #2
    Your mysql_query($sq l)statement failed i.e., it returned FALSE. Add error checking/handling to that statement to find out why it failed.

    Hint, you have a syntax (quoting) error in the query.

    Comment

    • Toxicous8
      New Member
      • Oct 2015
      • 57

      #3
      Error checking and handling? what is it?
      And where's the quoting error please? tnx

      Comment

      • Toxicous8
        New Member
        • Oct 2015
        • 57

        #4
        Error checking and handling? what is it? If it's like

        Code:
        $error = error_reporting();
        , then i don't see how it would be useful to fix this problem. If not then what is it?

        And where's the quoting error please? tnx

        Comment

        Working...