473,773 Members | 2,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

77 New Member
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 2357
Markus
6,050 Recognized Expert Expert
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 Recognized Expert Expert
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 New Member
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 New Member
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 Recognized Expert Expert
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
3675
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 resource even though if I echo the query to the browser and cut and paste it into the command line I get valid results.
2
7992
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, Quantity FROM restorder_item WHERE Order_Number =58 The code I use to do it is.... $query = "select Menu_Item, Quantity from restorder_item"; $query .= " where Order_Number = ".$_REQUEST;
5
3059
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 write some PHP code which should, I think, be able to to auto create the tables. The SQL looks like this:
3
2115
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
16932
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 not a valid MySQL result resource in /home/jplane/certcent/phpweb/quiz/index.php on line 21 PHP CODE:
1
2713
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 line 113 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on line 127 My code is below. Any help would be much appreciated. ...
1
1530
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 manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in...
10
1822
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'); Although I'm sure the connection to the database is ok, I sometimes get an error of this kind: *Warning*: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in ... This does not happen every time i run the script, only...
2
2200
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 /home/asi50080/public_html/onlineadv/category.php on line 143 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/asi50080/public_html/onlineadv/category.php on line 155
0
9621
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6717
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.