警告:mysql_result()[function.mysql-result]:无法跳转到MySQL结果索引5的第1行

时间:2013-11-11 06:42:08

标签: php mysql

我正在尝试执行以下代码。但得到了这个错误:  “mysql_result()[function.mysql-result]:无法跳转到MySQL结果索引5的第1行” ,第0个索引处的值得到打印但剩余给出给出上述错误。我的代码是:

$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;
}

可以解释错误。

1 个答案:

答案 0 :(得分: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;

}