PHP错误:无法跳转到MySQL上的第0行

时间:2013-01-10 05:43:04

标签: php mysql

出于某种原因,PHP在我的网络服务器上抛出错误,但不是在本地:

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 16 in /home/a8576801/public_html/indev/core/functions/users.php on line 79

现在,第79行的相关功能如下:

function user_id_from_username($username) {
    $username = sanitize($username);
    return mysql_result(mysql_query("SELECT `user_id` FROM `users` WHERE `user_name` = '$username'"), 0, 'user_id') or die(mysql_error());
}

2 个答案:

答案 0 :(得分:0)

$ username可能是NULL。回显用户名并确认有与之关联的值。

可能还想查看Unable to jump to row 0 on MySQL result index 13

答案 1 :(得分:0)

哇好抱歉大家。对我来说是愚蠢的错误。我在错误的文件中调用了该函数。

固定!