Menu

Getting 'invalid argument' error - fix?

Help
Anonymous
2003-06-19
2003-06-20
  • Anonymous

    Anonymous - 2003-06-19

    I am getting

    Warning: Invalid argument supplied for foreach() in /home/rf/phpGedView/useradmin.php on line 147

    when I access the Admin/User Adminstration page and no users show in the list.  I can add a user and the login works properly.

     
    • John Finlay

      John Finlay - 2003-06-19

      This is only a problem in the MySQL version and you can fix it like this:

      On line 146 of useradmin.php add the following line:
      $users = getUsers();

      Then add the following function to the authentication.php file:
      //----------------------------------- getUsers
      //-- return an array of user arrays
      function getUsers() {
          global $TBLPREFIX;
          $sql = "SELECT * FROM ".$TBLPREFIX."users";
          $res = dbquery($sql);
          $users = array();
          if ($res) {
              while($user_row = mysql_fetch_array($res)) {
                  $user = array();
                  $user["username"]=$user_row["u_username"];
                  $user["fullname"]=$user_row["u_fullname"];
                  $user["password"]=$user_row["u_password"];
                  if ($user_row["u_canadmin"]=='Y') $user["canadmin"]=true;
                  else $user["canadmin"]=false;
                  if ($user_row["u_canedit"]=='Y') $user["canedit"]=true;
                  else $user["canedit"]=false;
                  $users[$user_row["u_username"]] = $user;
              }
          }
          return $users;
      }

      Sorry about this error.
      --John

       
    • Anonymous

      Anonymous - 2003-06-20

      Worked like a charm - thanks for the GREAT support.

       

Log in to post a comment.