423,309 Members | 2,163 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,309 IT Pros & Developers. It's quick & easy.

Can't login to my own forum, that sucks

P: 57
I'm unable to login? plz help

Expand|Select|Wrap|Line Numbers
  1.  
  2. session_start();
  3. include_once ('dbconnect.php');
  4.  
  5.  
  6. if(isset($_POST['log'])) {
  7.     $dbselect = mysql_query("USE codb");
  8.     $uname = mysql_real_escape_string($_POST['username']);
  9.     $upass = mysql_real_escape_string($_POST['pass']);
  10.     $sql = mysql_query("SELECT * FROM users WHERE username=".$uname." AND password=".$upass." LIMIT 1");
  11.     $res = mysql_query($sql);
  12.  
  13.  
  14.     if(mysql_num_rows($res) == 1) {
  15.         $row = mysql_fetch_assoc($res);
  16.         $_SESSION['user'] = $row['user_id'];
  17.         header("Location: speak.php");
  18.     }else{
  19.         $error = error_reporting(E_ALL^E_WARNING);
  20.         echo "<script>alert('Wrong details!');</script>";
  21.     }
  22.  
  23. }
  24.  
  25.  



It displays
Expand|Select|Wrap|Line Numbers
  1.  
  2. Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\log.php on line 14
  3.  
Jan 30 '16 #1
Share this Question
Share on Google+
3 Replies


Expert Mod 100+
P: 588
Your mysql_query($sql)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.
Jan 30 '16 #2

P: 57
Error checking and handling? what is it?
And where's the quoting error please? tnx
Feb 1 '16 #3

P: 57
Error checking and handling? what is it? If it's like

Expand|Select|Wrap|Line Numbers
  1. $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
Feb 1 '16 #4

Post your reply

Sign in to post your reply or Sign up for a free account.