0

i am trying to execute the following code. but got this error: "mysql_result() [function.mysql-result]: Unable to jump to row 1 on MySQL result index 5" , the value at 0th index got print but remaining give give the error mentioned above. my code is:

$s = mysql_query( "SELECT USER_NAME, LOCATION, LANGUAGE, PHONE FROM USERS WHERE USER_ID = '$userid'" );
    if(mysql_fetch_row( $s ) ){
        $username = mysql_result( $s, 0 );
        $location = mysql_result( $s, 1 );
        $language = mysql_result( $s, 2 );
        $phoneNum = mysql_result( $s, 3 );

    echo $username;
    echo $location;
    echo $language;
    echo $phoneNum;
}

can any please explain the error.

user2809576
  • 121
  • 1
  • 2
  • 11

1 Answers1

0
$s = mysql_query( "SELECT USER_NAME, LOCATION, LANGUAGE, PHONE FROM USERS WHERE USER_ID = '$userid'" );

$row    = mysql_fetch_row($s);
    if($row){
        $username = $row[0];
        $location = $row[1];
        $language = $row[2];
        $phoneNum = $row[3];

    echo $username;
    echo $location;
    echo $language;
    echo $phoneNum;

}
Surabhil Sergy
  • 1,946
  • 1
  • 23
  • 40