FUNKAM35 Posted June 6, 2014 Share Posted June 6, 2014 <?php global $places; $comm = $GLOBALS["location"]; $comm=trim($comm); while(list($one,$two) = each($places)) { echo "<option value=\"$two\""; if ( $two == $comm)echo "selected "; echo ">$two</option>\n" ; } ?> Variable passed to each() is not an array or object Hi, my code works fine but it is giving the error message Please can anyone help? Thanks Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted June 6, 2014 Share Posted June 6, 2014 The error is message is straight forward. The variable $places you past to each() is not array or an object. How is the $places variable defined and why are casting it as global? Quote Link to comment Share on other sites More sharing options...
FUNKAM35 Posted June 6, 2014 Author Share Posted June 6, 2014 hi, thank you for your reply. the $places are a set list of places in the variables file. don't know why I did the globals, think because it was set list. Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted June 6, 2014 Share Posted June 6, 2014 the $places are a set list of places in the variables file What does that mean? Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted June 6, 2014 Share Posted June 6, 2014 Note that you can see what type of variable $places is with var_dump(): http://www.php.net//manual/en/function.var-dump.php Quote Link to comment 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.