0

I am making a website with registration and login. So I have a database where users information in stored. Now I want to get some info from this database. To be exact I want to get users password using PHP code. Right now my code is following:

<?php
    $result = mysql_query('SELECT password FROM users');
    echo mysql_result($result, 4);
?>

I get this message, when I try to run my code:

Warning: mysql_result(): Unable to jump to row 4 on MySQL result index 8 in C:\xampp2\htdocs\Praks\seaded.php on line 20

How could I make it work?

user244902
  • 143
  • 4
  • 14

1 Answers1

1

it seems that do not have 5 passwords rows stored in your database. so you can try :

 echo mysql_result($result, 0);//return first password from your query result

or you can do like this to echoing all passwords:

$result = mysql_query('SELECT password FROM users');
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    printf("password: %s ", $row["password"]);
}

notice: all mysql_* functions are deprecated. You should move to PDO or mysqli.

Awlad Liton
  • 9,366
  • 2
  • 27
  • 53