Hey all,

I've got this user authentication class that grabs a users profile from the database. 
Anyhow, I need to also insert the groups that this user belongs to along with 
permission settings. I'm having trouble figuring out how to store and read back the 
data. I'm using PHP4. Here's the code:

// Grab the list of groups that this user belongs to
$sql = 'select groupname,a,r,w,d from auth_usergroups where username = "' . $u . '"';
$AUTHSQL .= $sql . '<br>';
$query = mysql_query($sql);

if (mysql_error() != "") {
 $AUTHMSG .= mysql_error() . "<br>";
}

if (mysql_num_rows($query) > 0) {
 $counter = 0;
 $this->group = array();
 while ($rs = mysql_fetch_array($query)) {
  $this->group[$counter] = array(
   "name" => $rs[groupname],
   "a" => $rs[a],
   "r" => $rs[r],
   "w" => $rs[w],
   "d" => $rs[d]
  );
  $counter++;
 }
 mysql_free_result($query);
}

I've tried this in a few different ways and everytime I end up with blank values or 
I'm just not calling them correctly. Can anyone give me a few pointers as to how you 
would go about this? By the way, this is inside the classes initialization function so 
there are other properties like $this->username, $this->firstname, etc. That's why I 
need this to be a multidimensional array.

Thanks,
Toby

Reply via email to