473,585 Members | 2,673 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result,

2 New Member
Heya, I get these 2 errors:
Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 20
You have not entered all the fields
Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 34
Sorry You failed to enter the correct old password

I was wondering if anyone could help me, I have said where the lines are,
Please help,
[PHP]<?php
// Mysql
include ('mysql_connect .php');
//
$oldpass=$_POST['oldpass'];
$newpass=$_POST['newpass'];
$cnewpass=$_POS T['cnewpass'];
$numrows = mysql_num_rows( $res);
//
if (($oldpass==NUL L)||( $newpass==NULL) ||( $cnewpass==NULL )) {
echo "You have not entered all the fields";
}else{
}
//
if($newpass!=$c newpass) {
echo "Passwords do not match";
} else {
}
//
$sql = "UPDATE users SET password = '".md5($newpass )."' WHERE username = '".$_SESSION['s_username']."' AND password = '".md5($oldpass )."' ";
$res = mysql_query($sq l,$dbc) or die (mysql_error()) ;
$numrows = mysql_num_rows( $res);
if ($numrows >0) {
echo "your password has been changed ";
} else {
echo "Sorry You failed to enter the correct old password";
}
mysql_query($sq l,$dbc) or die (mysql_error()) ;
?>[/PHP]
Jun 9 '07 #1
4 7825
bucabay
18 New Member
Heya, I get these 2 errors:
Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 20
You have not entered all the fields
Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 34
Sorry You failed to enter the correct old password

I was wondering if anyone could help me, I have said where the lines are,
Please help,
[PHP]<?php
// Mysql
include ('mysql_connect .php');
//
$oldpass=$_POST['oldpass'];
$newpass=$_POST['newpass'];
$cnewpass=$_POS T['cnewpass'];
$numrows = mysql_num_rows( $res);
//
if (($oldpass==NUL L)||( $newpass==NULL) ||( $cnewpass==NULL )) {
echo "You have not entered all the fields";
}else{
}
//
if($newpass!=$c newpass) {
echo "Passwords do not match";
} else {
}
//
$sql = "UPDATE users SET password = '".md5($newpass )."' WHERE username = '".$_SESSION['s_username']."' AND password = '".md5($oldpass )."' ";
$res = mysql_query($sq l,$dbc) or die (mysql_error()) ;
$numrows = mysql_num_rows( $res);
if ($numrows >0) {
echo "your password has been changed ";
} else {
echo "Sorry You failed to enter the correct old password";
}
mysql_query($sq l,$dbc) or die (mysql_error()) ;
?>[/PHP]
The function "mysql_num_rows ()" returns the number of rows in the mysql result of a SELECT or SHOW statement.
An UPDATE statement does not return any rows. To find out if the update actually worked, or affected some rows in the database table, then use: "mysql_affected _rows()"

If you're doing an INSERT and want to know the id of the row the insert was made, use: "mysql_insert_i d()"
Jun 9 '07 #2
epots9
1,351 Recognized Expert Top Contributor
on line 10, u test if the fields are empty echo a message, but then u still continue to trying to update the database. After the echo put [PHP]exit();[/PHP] so the script doesn't not continue, or change the header to redirect to another page (ie. the page with the fields).
Jun 9 '07 #3
Ryanlawrence1
2 New Member
I have done what you have said but i still have the same error:
Warning: mysql_affected_ rows(): supplied argument is not a valid MySQL-Link resource in /home/themepar/public_html/changepass.php on line 20
You have not entered all the fields
Warning: mysql_affected_ rows(): supplied argument is not a valid MySQL-Link resource in /home/themepar/public_html/changepass.php on line 35
Sorry You failed to enter the correct old password
Thanks For your help anyway,
[PHP]<?php
session_start() ;
if (!isset($_SESSI ON['s_username'])) {
header("Locatio n: login.php");
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Change Pass</title>
</head>
<body>
<?php
// Mysql
include ('mysql_connect .php');
//
$oldpass=$_POST['oldpass'];
$newpass=$_POST['newpass'];
$cnewpass=$_POS T['cnewpass'];
$numrows = mysql_affected_ rows($res);
//
if (($oldpass==NUL L)||( $newpass==NULL) ||( $cnewpass==NULL )) {
echo "You have not entered all the fields";
}else{
exit();
}
//
if($newpass!=$c newpass) {
echo "Passwords do not match";
} else {
}
//
$sql = "UPDATE users SET password = '".md5($newpass )."' WHERE username = '".$_SESSION['s_username']."' AND password = '".md5($oldpass )."' ";
$res = mysql_query($sq l,$dbc) or die (mysql_error()) ;
$numrows = mysql_affected_ rows($res);
if ($numrows >0) {
echo "your password has been changed ";
} else {
echo "Sorry You failed to enter the correct old password";
}
mysql_query($sq l,$dbc) or die (mysql_error()) ;
?>[/PHP]
Jun 9 '07 #4
pbmods
5,821 Recognized Expert Expert
Does mysql_connect.p hp set the value of $res? That won't work unless:
  • $res is global, or...
  • mysql_connect.p hp returns a value and you use the include statement to set the *local* variable $res:

mysql_connect.p hp:
Expand|Select|Wrap|Line Numbers
  1. return mysql_connect( ... );
  2.  
changepass.php:
Expand|Select|Wrap|Line Numbers
  1. $res = include('mysql_connect.php');
  2.  
Jun 10 '07 #5

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

Similar topics

2
7972
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 .=...
2
4236
by: Willem Berendsen | last post by:
Hello, I setting up my mysql-server and php on IIS6 and it works almost fine. But I got the next error: Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in file.php on line 46. But I'am sure that the code is good, because I have use the code very much. Create a connection is working, mysql_query is working...
3
3425
by: Pratchaya | last post by:
Hi Everyone ============================================================== About PHP::: Error/Problem PHP Warning: mysql_fetch_array(): ============================================================== In the past i use my code/script work fine with Mandrake 9.1 - 10.1 ( + apache ,mysql ) Now i move to redhat EL4 with the same...
7
1912
by: Dejan | last post by:
Hi Sorry for my terreble english. On my local (win) comp i have apache+mysql+php 4.05 I'm counting rows using mysql_num_rows function, and everything works fine. When i upload php file on server it says: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in...
3
3905
by: petemaxi | last post by:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\tockholes\includes\menu.inc.php on line 9 <div class="left"> <div class="menu"> <div class="boxhead" style="text-align:center;"> <strong>Menu</strong> </div> <br /> <?php require ('includes/db_conn.inc.php'); $query =...
2
16916
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
2698
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...
4
5023
by: fisherd | last post by:
When i run this code, i keep getting this message; Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\checklogin.php on line 26 i use this code to check login details. Here is the code for the pages that i used. main_login.php <html> <body>
2
16971
by: poreko | last post by:
I am connecting to my database using Object oriented PHP. My query is returning results but at the end of my table,at the bottom of the page I keep having this error when I run my program: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\mysql_class_2.php on line 45. Can anyone help me? ...
0
7900
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...
0
7832
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...
0
8192
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8204
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6592
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...
1
5705
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...
0
3853
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2338
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1442
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.