Hydrian Posted September 3, 2012 Share Posted September 3, 2012 Iv got a script. Now it it tells me there is a unexpected { at the end of line 9 which is i dont know why it tells me its unexpected. Please help, im a learning phper while (($row = mysql_fetch_assoc($result)) !== false{ $users[] = $row; } Full Script <?php // fetchs all of the users from the table function fetch_users(){ $result = mysql_query('SELECT `user_id` AS `id`, `user_username` AS `username` FROM `users` '); $users = array(); while (($row = mysql_fetch_assoc($result)) !== false{ $users[] = $row; } return $users; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/267936-unexpcpected/ Share on other sites More sharing options...
requinix Posted September 3, 2012 Share Posted September 3, 2012 You're missing a closing parenthesis. Quote Link to comment https://forums.phpfreaks.com/topic/267936-unexpcpected/#findComment-1374801 Share on other sites More sharing options...
Hydrian Posted September 3, 2012 Author Share Posted September 3, 2012 where am i missing it. Quote Link to comment https://forums.phpfreaks.com/topic/267936-unexpcpected/#findComment-1374802 Share on other sites More sharing options...
Hydrian Posted September 3, 2012 Author Share Posted September 3, 2012 Where am missing those () Quote Link to comment https://forums.phpfreaks.com/topic/267936-unexpcpected/#findComment-1374804 Share on other sites More sharing options...
Hydrian Posted September 3, 2012 Author Share Posted September 3, 2012 HELP Quote Link to comment https://forums.phpfreaks.com/topic/267936-unexpcpected/#findComment-1374805 Share on other sites More sharing options...
requinix Posted September 3, 2012 Share Posted September 3, 2012 It's fine that you're learning PHP but at some point you have to try to figure things out yourself. It takes like, what, 5 seconds to make a change and test it out? I've told you what you're missing and PHP has told you that it found something unexpected. Any guesses as to what it was expecting? Quote Link to comment https://forums.phpfreaks.com/topic/267936-unexpcpected/#findComment-1374808 Share on other sites More sharing options...
matthew9090 Posted September 3, 2012 Share Posted September 3, 2012 It's simple, you cannot have a check outside the parenthasis while ($row = mysql_fetch_assoc($result) !== false){ $users[] = $row; } Quote Link to comment https://forums.phpfreaks.com/topic/267936-unexpcpected/#findComment-1374815 Share on other sites More sharing options...
PFMaBiSmAd Posted September 3, 2012 Share Posted September 3, 2012 The extra !== false comparison is unnecessary. The while() statement already tests if the condition is true/false. Quote Link to comment https://forums.phpfreaks.com/topic/267936-unexpcpected/#findComment-1374874 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.