mdmartiny Posted May 17, 2012 Share Posted May 17, 2012 Hello everyone, I am writing some code for a login script. I keep getting the error Resource ID #13. What does this mean and how can I fix it? Here is the code that I am having trouble with function user_id_from_username($username) { $username = sanitize($username); $query = mysql_query("SELECT `user_id` FROM `users` WHERE `username` = '$username'"); return mysql_result($query, 0, 'user_id'); } function login($username, $password) { $user_id = user_id_from_username($username); $username = sanitize($username); $password = md5($password); $query = "SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username' AND `password` = '$password'"; return (mysql_result(mysql_query($query), 0) == 1) ? $user_id : false; } Link to comment https://forums.phpfreaks.com/topic/262656-resource-id-13/ Share on other sites More sharing options...
requinix Posted May 17, 2012 Share Posted May 17, 2012 1. What error message on what line? 2. user_id_from_username assumes that the query returns something. Reality is that it might not find any matching rows. Link to comment https://forums.phpfreaks.com/topic/262656-resource-id-13/#findComment-1346253 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.