What is wrong with mysql_num_rows()?

zoot2

New Member
I have this code to get the user name that a friend has messaged to someone like user to from message. \[code\]mysql_num_rows\[/code\] is not working and my user names come up as unknown. Does this have something to do with \[code\]mysql_num_rows()\[/code\]?\[code\]function getusername($userid) { $sql = "SELECT username FROM user WHERE `id` = '".$userid."' LIMIT 1"; $result = mysql_query($sql); // Check if there is someone with this id if(mysql_num_rows($result)) { // if yes get his username $row = mysql_fetch_row($result); return $row[0]; } else { // if not, name him Unknown return "Unknown"; }}\[/code\]
 
Back
Top