473,327 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Resource id #4 in all case while username and password is not correct

Hi all,

i'm a new user of PHP,

at the moment, i have queries regarding the "Resource id #4"

following is my code
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $con=mysql_connect("localhost","root","","register");
  3. $db=mysql_select_db("register",$con);
  4.  
  5.  
  6. if(isset($_POST['login']))
  7. {
  8. $username=$_POST['uname'];
  9. $password=$_POST['pwd'];
  10.  
  11.  
  12.  
  13.  
  14. $sql1 = "SELECT * FROM `reg` where username='$username' AND password='$password'";
  15.  
  16.  
  17. $query1= mysql_query($sql1);
  18. echo $query1;
  19.  
  20.  if (($query1)>0)
  21.  {
  22. while ($rows=mysql_fetch_array($query1))
  23. {
  24.  
  25.  
  26.     $_SESSION['unme']=$rows['username'];
  27.     $_SESSION['pwd']=$rows['password'];
  28.     $_SESSION['photo']=$rows['photo'];
  29.  
  30.     echo $_SESSION['unme'];
  31.      echo $_SESSION['pwd'];
  32.       echo $_SESSION['photo'];
  33.  
  34.  
  35.  
  36.  
  37. if (($username==$_SESSION['unme'])&&($password==$_SESSION['pwd']))
  38. {
  39.     /*header("location:home.php?firstname=".$_SESSION['unme']);*/
  40.     echo "ghngjh";
  41.  
  42. }
  43.  
  44. }
  45.  }
  46. else
  47. {
  48.     echo "nooooo";
  49. }
  50.  
  51.  
  52. }
  53.  
  54. mysql_close($con);
Apr 21 '14 #1
1 1535
Dormilich
8,658 Expert Mod 8TB
that’s correct. if you print out a resource data type, that is the output you get.

you explicitly have to fetch the row count with mysql_num_rows()


PS. the mysql functions are deprecated, use PDO or MySQLi instead.
Apr 22 '14 #2

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

Similar topics

4
by: Lobang Trader | last post by:
Hi all, I am trying to create a username and a password class. I would like to know what are the RECOMMENDED minimum and maximum length for both fields? These fields will be something like...
2
by: john brown | last post by:
There is a web page that I access frequently and would like to automate the authentication of the username and password. I would like to user a perl script but I'm not really sure about the steps....
14
by: John Davis | last post by:
Anyone knows how to create the username/password authorization dialog in ASP? Thanks, John
8
by: Noel Volin | last post by:
Anyone who can help here is much appreciated. I am trying to programmatically log onto a website. I am using the code provided in VS for the AuthenticationManager Class example (...
1
by: thoducng | last post by:
I am writing some code to access share folder on a remote network. DirectoryInfo dicInfo = new DirectoryInfo("remoteNetwork\shareFolder"); if (dicInfo.Exists) { //application code...
12
by: Cecil | last post by:
Does this make sense for a logon table: CREATE TABLE Logon ( ID INT NOT NULL IDENTITY PRIMARY KEY, name VARCHAR(15) NOT NULL, password VARCHAR(15) NOT NULL ) GO CREATE UNIQUE INDEX...
0
by: nemo | last post by:
I've included a list of username/password combinations in the Web.Config file and I've a simple aspx page with a username and password field for the users to log in. While the password field seems...
4
by: nemo | last post by:
I've included a list of username/password combinations in the Web.Config file and I've a simple .aspx page with a username and password field for the users to log in. While the password field is...
6
by: carl2k2 | last post by:
Ok trying to setup a simple user login system The first attempt I just used if statements for example If txtusername = "carl" and txtpassword = "password" Then OK = True Form4.show else...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.