PDA

View Full Version : print_membergroup_row() and array() Help !


K a M a L
08-22-2011, 06:37 PM
sorry , it is my second thread today
I'm programming admin page and used the function
print_membergroup_row (string $title, [string $name = 'membergroup'], [integer $columns = 0], [mixed $userarray = NULL])
My strange problem is with last arrtibute , it is used to prefill usergrups with current values
when I write print_membergroup_row("Title", "recusergroup",2,array('usergroupid' => 0, 'membergroupids' => '1,2,3,4,5,6'));

it works correctly and groups 1,2,3,4,5,6 are marked
I have variabe $groups=1,2,3,4,5,6
when I write print_membergroup_row("Title", "recusergroup",2,array('usergroupid' => 0, 'membergroupids' => $groups));
I get only group 1 marked
then I set
$groups='1,2,3,4,5,6'
it doesn't work correctly
the first and last number are ignored !! and groups 2,3,4,5 only marked !

kh99
08-22-2011, 06:46 PM
I don't see any reason that this:

print_membergroup_row("Title", "recusergroup",2,array('usergroupid' => 0, 'membergroupids' => '1,2,3,4,5,6'));


would not be the same as this:
$groups = '1,2,3,4,5,6';
print_membergroup_row("Title", "recusergroup",2,array('usergroupid' => 0, 'membergroupids' => $groups));

(but you definitely need the quotes around the list).

Also, it looks like there can not be any spaces, so make sure you're not doing this:
$group = ' 1,2,3,4,5,6 ';

K a M a L
08-22-2011, 07:02 PM
yes , I tried it with space and without and the problem is the same
but I made a solution

$groups= 1,2,3,4,5,6; // without quotes
print_membergroup_row("Title", "recusergroup",2,array('usergroupid' => 0, 'membergroupids' => "'0,".$groups.",0'"));

I added 0 at start and zero at end so it ignores the starting zero and end zero
but I'm still intersted to know why this happens

kh99
08-22-2011, 07:09 PM
$groups= 1,2,3,4,5,6 // without quotes


Strange, I get an error when I try that in a test file. Maybe there's some option I don't know about.

K a M a L
08-22-2011, 07:14 PM
You may forgot the semicolon :)

Badshah93
08-22-2011, 07:17 PM
I just tried

$groups = '1,2,3,4,5,6';

print_membergroup_row("Title", "recusergroup",2,array('usergroupid' => 0, 'membergroupids' => $groups));

and its working well..

kh99
08-22-2011, 07:17 PM
You may forgot the semicolon :)

I tried it with a semicolon, I get this error:

Parse error: syntax error, unexpected ',' in test.php on line 9


Oh well, as long as you got it working.

K a M a L
08-22-2011, 07:34 PM
thank you your help and time
by the way , I copied your code and it is working without problems
can you find the diffrence between your code and mine ?
I think the diffrence is that i didn't sleep for 20 hours :D

Badshah93
08-22-2011, 07:56 PM
thank you your help and time
by the way , I copied your code and it is working without problems
can you find the diffrence between your code and mine ?
I think the diffrence is that i didn't sleep for 20 hours :D

write ur codes always in good notepad software like notepad++.