我收到以下错误块(值得注意的是,此错误会在重复之后立即重复,为简单起见,我仅复制了一次迭代):

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 9 in /home/a-slsa/www/classes/ASC/ASCStaffData.php on line 89

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 9 in /home/a-slsa/www/classes/ASC/ASCStaffData.php on line 91

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 9 in /home/a-slsa/www/classes/ASC/ASCStaffData.php on line 93

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 9 in /home/a-slsa/www/classes/ASC/ASCStaffData.php on line 95

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 9 in /home/a-slsa/www/classes/ASC/ASCStaffData.php on line 97

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 9 in /home/a-slsa/www/classes/ASC/ASCStaffData.php on line 99

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 9 in /home/a-slsa/www/classes/ASC/ASCStaffData.php on line 101

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 9 in /home/a-slsa/www/classes/ASC/ASCStaffData.php on line 103


引用的行如下(是的,我知道使用不推荐使用的功能很糟糕,但这不是我的代码-从其他人那里继承了一个相当大的项目):

    $ascStaff['staffId'] = (mysql_result($dbStaffData->fetch,0,"STAFF_ID") ?
                                mysql_result($dbStaffData->fetch,0,"STAFF_ID") : NULL);

    $ascStaff['ownership'] = (mysql_result($dbStaffData->fetch,0,"OWNERSHIP") ?
                                mysql_result($dbStaffData->fetch,0,"OWNERSHIP") : NULL);

    $ascStaff['firstName'] = (mysql_result($dbStaffData->fetch,0,"FIRST_NAME") ?
                                mysql_result($dbStaffData->fetch,0,"FIRST_NAME") : NULL);

    $ascStaff['lastName'] = (mysql_result($dbStaffData->fetch,0,"LAST_NAME") ?
                                mysql_result($dbStaffData->fetch,0,"LAST_NAME") : NULL);

    $ascStaff['ritEmail'] = (mysql_result($dbStaffData->fetch,0,"RIT_EMAIL") ?
                                mysql_result($dbStaffData->fetch,0,"RIT_EMAIL") : NULL);

    $ascStaff['otherEmail'] = (mysql_result($dbStaffData->fetch,0,"OTHER_EMAIL") ?
                                mysql_result($dbStaffData->fetch,0,"OTHER_EMAIL") : NULL);

    $ascStaff['address'] = (mysql_result($dbStaffData->fetch,0,"ADDRESS") ?
                                mysql_result($dbStaffData->fetch,0,"ADDRESS") : NULL);

    $ascStaff['phoneNumber'] = (mysql_result($dbStaffData->fetch,0,"PHONE_NUMBER") ?
                                    mysql_result($dbStaffData->fetch,0,"PHONE_NUMBER") : NULL);


令我感到困惑的是,当手动将查询输入到mysql中时,查询效果很好。

知道为什么我会收到此错误或如何解决它吗?

最佳答案

根据我的评论:不建议使用mysql扩展名,因此即使您使用的是旧代码库,也应考虑升级到mysqli

鉴于此,通常此错误表示查询失败。

检查查询的方式与此类似:

$result = mysql_query("SELECT foo FROM bar WHERE foo = 1");
if(!$result || !mysql_num_rows($result))
{
    die("Empty dataset.");
}

10-07 21:50