Page 1 of 1

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

Posted: Tue Aug 04, 2009 4:43 am
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.

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

Posted: Tue Aug 04, 2009 6:25 am
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]'"));

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

Posted: Tue Aug 04, 2009 11:12 pm
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

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

Posted: Wed Aug 05, 2009 12:16 am
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 ';