unemployment Posted October 1, 2011 Share Posted October 1, 2011 I'm trying to get the data for a single user, but I have a loop error and I don't understand why. Can someone please clarify where I went wrong? function fetch_user_info_mini_profile_by_uid($uid){ $uid = (int)$uid; $sql = "SELECT '${uid}' AS `uid`, `username` AS username, `firstname`, `lastname`, `accounttype`, `country`, `state`, `city`, FROM `users` WHERE `id` = '${uid}'"; $query = mysql_query($sql); $profile = array(); while (($row = mysql_fetch_assoc($query)) !== false) { $profile = array( 'uid' => $row['uid'], 'firstname' => $row['firstname'], 'lastname' => $row['lastname'], 'username' => $row['username'], 'accounttype' => ($row['accounttype'] == '1') ? 'Entreprenuer' : 'Investor', 'country' => $row['country'], 'state' => $row['state'], 'city' => $row['city'], 'display_name' => ucwords("${row['firstname']} ${row['lastname']}"), ); } $profile['avatar'] = getUserAvatar($row['username']); return $profile; } Link to comment https://forums.phpfreaks.com/topic/248237-php-loop-error/ Share on other sites More sharing options...
Pikachu2000 Posted October 1, 2011 Share Posted October 1, 2011 I can virtually guarantee your query is failing. What is the error you're getting? Link to comment https://forums.phpfreaks.com/topic/248237-php-loop-error/#findComment-1274754 Share on other sites More sharing options...
unemployment Posted October 1, 2011 Author Share Posted October 1, 2011 Yeah, you're right. Those commas can kill you. I guess I wasn't looking in the right spot. Link to comment https://forums.phpfreaks.com/topic/248237-php-loop-error/#findComment-1274756 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.