By maori on
Hi all
trying to remake my module for D7 and i saw the while loop is no longer used so i tried altering to how it was advised such as
function _getUsers() {
$query = "select uid, name from users where uid and uid !=1> 0 ";
$result = db_query($query);
$users = array();
foreach ($result as $users){
$users[$user->uid] = $user->name;
}
return $users;
}
but this gives me a error
Fatal error: Cannot use object of type stdClass as array
for this line
$users[$user->uid] = $user->name;
and i cant find out why or how to solve it :( all this used to do is get all the users from the dab and in my form it will display the names in a select element
any help much appreacted
Comments
It looks like $users is an
It looks like $users is an object, not an array, but you are trying to use it like an array.
Contact me to contract me for D7 -> D10/11 migrations.
How are you debugging?
Hi,
Are you developing on a local installation or are you still trying to develop on a remote location using "print" statements?
Should be
However, the real problem is your development environment. Never develop on a remote location. Alway develop on a local installation where you have access to the system logs and can run Drupal through a source code debugger like xdebug. If you were using a source code debugger, you would seen how to correct the code in a second. Developing on a remote server is like trying to develop over the telephone :)
hi guys thanks for the input
hi guys
thanks for the input install centos on my spare machine as we speak :)
Please rename your post
Hi,
Glad to have helped. If your issue is solved please abide by the forum guide lines http://drupal.org/forum-posting :
Along the same lines, please rename the subject line of your post so that other folks in the community can use it as a reference . How about "Creating a list of user names with Drupal 7". That way someone else trying to figure out how to select user names from the database will find your post and not feel obligate to post an additional question.
heya Oooooops sorry forgot
heya
Oooooops sorry forgot about that
both have now been done
Regards