Warning: mysql_result() [function.mysql-result]:

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mandadi
Forum Newbie
Posts: 3
Joined: Tue Aug 04, 2009 4:26 am

Warning: mysql_result() [function.mysql-result]:

Post by mandadi »

Hi all,

I am a new to PHP i've created a login pages.I'm trying to execute the change password code it gives me the below warning message, and the changed password doesn't reflect in the database.
-----Warning: mysql_result() [function.mysql-result]: Unable to jump to row 7 on MySQL result index 4 in C:\wamp\www\new\check.php on line 13----


and the code is

Code: Select all

<?php
session_start();
include "dbconnection.php";  //database=sampledb,table=users
$result = mysql_query("select password from users where username='$_POST[username]' and userID='$_POST[userID]'");
if(!$result)
{
echo "oops! The Username you entered does not exist";
}
else
if($_POST['password']!= mysql_result($result,0))
{
echo "You entered an incorrect password";
}
else if($_POST['newpassword']!=$_POST['confirmnewpasssword'])
{
echo "The new password and confirm new password fields must be the same";
}
else
$sql=mysql_query("UPDATE users SET password='$_POST[newpassword]' where username='$_POST[username]'");
if($sql)
{
echo "Congratulations You have successfully changed your password";
}
?>
 

Please anyone can help me to fix this problem.

Thanks in advance,
Regards,
Swathi.
User avatar
bala_1225
Forum Commoner
Posts: 29
Joined: Tue Jul 28, 2009 3:20 am
Location: chennai,india

Re: Warning: mysql_result() [function.mysql-result]:

Post by bala_1225 »

hi
u can try this one..
$result = mysql_query(mysql_fetch_array("select password from users where username='$_POST[username]' and userID='$_POST[userID]'"));
mandadi
Forum Newbie
Posts: 3
Joined: Tue Aug 04, 2009 4:26 am

Re: Warning: mysql_result() [function.mysql-result]:

Post by mandadi »

Hi,


Thanks for your advise Bala,I tried the code which you sent me but it was given this warning message

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\new\check.php on line 8


Thanks &regards,
Swathi
User avatar
bala_1225
Forum Commoner
Posts: 29
Joined: Tue Jul 28, 2009 3:20 am
Location: chennai,india

Re: Warning: mysql_result() [function.mysql-result]:

Post by bala_1225 »

HI,

select password from users where username='$_POST[username]' and userID='$_POST[userID]---error...
Because your args r null for that reason only its showing warning error......

your mistake is $_POST['username']......


better u can use like this method....

$userName = $_POST['username'];
$userId = $_POST['userID'];

select password from users where username='$userName' and userID='$userId ';
Post Reply