473,387 Members | 3,781 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,387 software developers and data experts.

PHP MySQL error: supplied argument is not a valid MySQL result resource

77
Hi,

I 'am trying to connect my sql database with my webpage for users log in. i have got this script so far but i keep getting the following error message which i cannot figure out..

could any1 help..
Expand|Select|Wrap|Line Numbers
  1. error:Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\checklogin.php on line 18
  2. Wrong Username or Password
  3.  
code:
Expand|Select|Wrap|Line Numbers
  1. <?
  2.  
  3. $hostname_mysql_connect = "localhost";
  4. $database_mysql_connect = "website_members";
  5. $username_mysql_connect = "root";
  6. $password_mysql_connect = "******";
  7. $tblname_mysql_connect ="members";
  8.  
  9. $mysql_connect = mysql_pconnect($hostname_mysql_connect, $username_mysql_connect, $password_mysql_connect, $tblname_mysql_connect) or trigger_error(mysql_error(),E_USER_ERROR); 
  10. mysql_select_db($database_mysql_connect) or die(mysql_error());
  11.  
  12. $myusername = $_POST['myusername'];
  13. $mypassword = $_POST['mypassword'];
  14.  
  15. $sql = "SELECT * FROM $tblname_mysql_connect WHERE username= '$myusername' and password='$mypassword'"; 
  16. $result = mysql_query($sql);
  17.  
  18. $count = mysql_num_rows($result); (line 18)
  19. if($count==1) {
  20.  session_register("myusername");
  21.  session_register("mypassword");
  22.  header("location:login_success.php");
  23.  }
  24.  else {
  25.  echo "Wrong Username or Password";
  26.  }
  27.  
  28. ?>
  29.  
many thanx
Jun 25 '08 #1
5 2342
Markus
6,050 Expert 4TB
On your mysql query add: or die(mysql_error())

Expand|Select|Wrap|Line Numbers
  1. $result = mysql_query($sql) or die(mysql_error());
  2.  
At a glance I can't see the problem. Maybe this will give a help.
Jun 25 '08 #2
Atli
5,058 Expert 4TB
Hi.

Please use [code] tags when posting your code examples. (See How to ask a question)

[code=php] ...PHP code goes here... [/code]

I've also changed the title of the thread to better describe it's contents.

Thank you.
Jun 26 '08 #3
Mubs
77
On your mysql query add: or die(mysql_error())

Expand|Select|Wrap|Line Numbers
  1. $result = mysql_query($sql) or die(mysql_error());
  2.  
At a glance I can't see the problem. Maybe this will give a help.

HI... I tried the following code and i got this for an error:

Unknown column 'password' in 'where clause'
Jun 26 '08 #4
Mubs
77
HI... I tried the following code and i got this for an error:

Unknown column 'password' in 'where clause'

I just figured it out...i mis spelt the password field..

many thanx for all posts..
Jun 26 '08 #5
Markus
6,050 Expert 4TB
I just figured it out...i mis spelt the password field..

many thanx for all posts..
Thought it would help.

Remember to use those 'or die(mysql_error())' on your mysql queries!
Jun 26 '08 #6

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

Similar topics

6
by: jerrygarciuh | last post by:
Hi all, I am iterating through a result set to generate a second set of queries but no matter what I do I get the error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result...
2
by: Noel Wood | last post by:
Hello I keep getting a warning ... Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in "name of my php file" when I run this query.... SELECT Menu_Item,...
5
by: lkrubner | last post by:
I have a webserver through Rackspace. I create a domain. I create an FTP user. I upload some files. I create a database called testOfSetupScript and then I create a database user named setup. I...
3
by: Klaus Hansen | last post by:
Hi all Using Windows XP, PHP4.3.11 and Mysql 4.1. Im a newbie to PHP and Mysql. Im trying to connect to the database with this script: <?php //list_db.php
2
by: techjohnny | last post by:
Error: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/jplane/certcent/phpweb/quiz/index.php on line 20 Warning: mysql_num_rows(): supplied argument is...
1
by: lsmamadele | last post by:
I am getting the following error messages in my search: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on...
1
by: nkosinathi | last post by:
Hi Guys im trying to write an import class where i can import information from .CSV file into my database. I am getting the following error Errors: You have an error in your SQL syntax. Check the...
10
by: Caffeneide | last post by:
I'm using a php script which performs three xml queries to other three servers to retrieve a set of ids and after I do a query to mysql of the kind SELECT * FROM table WHERE id IN ('set of ids');...
2
by: perhapscwk | last post by:
When I run my site from localhost, no error, but when I move it to webhosting, it show below error, why? Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.