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/262657-resource-id-13/ Share on other sites More sharing options...
smoseley Posted May 17, 2012 Share Posted May 17, 2012 Resource #13 is your connection. Doesn't say much. Break up the last line and tell us which line # you get the error on. $query = mysql_query($query); $count = mysql_result($query, 0); return $count == 1 ? $user_id : false; Link to comment https://forums.phpfreaks.com/topic/262657-resource-id-13/#findComment-1346234 Share on other sites More sharing options...
mdmartiny Posted May 17, 2012 Author Share Posted May 17, 2012 I figured out what the problem was... I had the field length in the table set to 20. Once I changed it to the 32 characters that md5 does it worked. Link to comment https://forums.phpfreaks.com/topic/262657-resource-id-13/#findComment-1346235 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.