473,394 Members | 1,645 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,394 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 1537
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.