Gossamer Forum
Quote Reply
List Of Users linked
Hi

Need some help on a global that will return a list of all the users in our database (each users name will be linked to his/her own page URL/Username)

Any ideas?
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] List Of Users linked In reply to
I have tried:

sub {
# Displays all Users.
my ($output,$sth,$user);
my $search_db= $DB->table('Users');
$search_db->select_options ('ORDER BY Username DESC');
$sth = $db->select;
while ($user = $sth->fetchrow_hashref) {
$output .= qq~<a href="$CFG->{db_cgi_url}/page.cgi?page=user&user=$row->{Username}">$row->{Username};~;
}
return $output;
}

But getting

Unable to compile 'users_list':

Any suggestions?
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] List Of Users linked In reply to
Two things, maybe if you haven't figured it out.

Make sure "sub {" doesn't have any trailing spaces.

Also, I have had problems at times using pointer notation in prints, quotes, etc, and found it sometimes better to assign them to strings:

$UserName = $row->{Username}

And use the simple $UserName.

Other than that, the syntax looks ok, except for the missing </A> tag, which shouldn't affect compile.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [katabd] List Of Users linked In reply to
How about the ; in the string? Just a guess.. but you never know :p

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] List Of Users linked In reply to
Actually, using the qq format is one way to be allowed to use things like ', " and : and ; in a string, ie: text.

The problems come from qq trying to interpret a pointer reference as partial text. It gets confused as to what is a variable/data and what is literal text, as it's goal is to try to be as literal as possible. My only major problems have been with the '->' notatations, and assigning them to a simple scaler before using any sort of print or string notation has usually solved the problem.

I'd be shocked/stunned/floored if the ; was causing the problems, since that is what the qq notation was designed to allow.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [katabd] List Of Users linked In reply to
You should have a better look at the error messages you get

Unable to compile 'users_list': Global symbol "$db" requires explicit package name at (eval 696) line 6. Global symbol "$row" requires explicit package name at (eval 696) line 8. Global symbol "$row" requires explicit package name at (eval 696) line 8.

This simply tells you that you have to code use'ing strict. If you do the following changes, it will work:
Code:
sub {
# Displays all Users.
my $search_db= $DB->table('Users');
$search_db->select_options ('ORDER BY Username DESC');
my $sth = $search_db->select;
my $output;
while (my $user = $sth->fetchrow_hashref) {
$output .= qq~<a href="$CFG->{db_cgi_url}/page.cgi?page=user&user=$user->{Username}">$user->{Username}</a><br /> ~;
}
return $output;
}

Ivan
-----
Iyengar Yoga Resources / GT Plugins

Last edited by:

yogi: Aug 25, 2003, 11:08 PM
Quote Reply
Re: [yogi] List Of Users linked In reply to
Thanks

That worked great..

I will have to work on a way to spann that list now.
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory