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; } Quote 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? Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/248237-php-loop-error/#findComment-1274756 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.