|
Posted by Bertman on 05/22/05 02:09
Hello,
I want to check an array, that's not the biggest problem. But now I'm having
a real weird situation. I have a file 'checklogin.php' this file put all the
groups where a user is member off in a array ($usergroups). I have a simple
file to test it 'test.php'. When I put 'test.php' in the 'root\login'
directory he will say exactly that I'm member off 2 groups (after I logged
in). But when I put 'test.php' in the 'root', he will say that i'm member
off 1 group. And when I put 'checklogin.php' in the root, he also will say
that i'm member off one group. It's pretty weird, because the files don't
have a path to other files except to 'incl\connect.php' (this file will make
a connection to my MySQL database)
Example below:
root\login\test1.php
- this one will say that i'm member off 2 groups
root\test.php
- this one will say that i'm member off 1 group
(root = top of the server)
root\login\checklogin.php
root\login\test1.php
root\test.php
# test.php
<?PHP
include 'include\connect.php';
include 'login\checklogin.php';
echo count($usergroups);
?>
# test1.php
<?PHP
include '..\include\connect.php';
include 'checklogin.php';
echo count($usergroups);
?>
# checklogin.php
<?php
if (isset($_COOKIE["UserID"])) {
if (isset($_COOKIE["Name"])) {
if (isset($_COOKIE["Pass"])) {
$userid = $_COOKIE["UserID"];
$name = $_COOKIE["Name"];
$pass = $_COOKIE["Pass"];
$query = mysql_query("SELECT * FROM cd_user WHERE User_loginname='$name'
AND User_password='$pass' AND User_id='$userid'") or die (mysql_error());
if (mysql_num_rows($query)=='0') {
$usergroup='0'; // 0 zijn public groepen
$usergroups='0';
$name='';
} else { # mysql_num_rows($query)=='0'
$usergroups='';
$count='0';
while($result = mysql_fetch_array($query)){
$userid = $result["User_id"];
$query1 = mysql_query("SELECT * FROM cd_user_and_group WHERE
User_id='$userid'") or die (mysql_error());
while($result1 = mysql_fetch_array($query1)){
$usergroups[$count] = $result1["Group_id"]; //Maak een array aan met
alle group nummers
$count = $count + 1;
}
}
} # mysql_num_rows($query)=='0'
}else{
//Pass not set.
$usergroup='0'; // 0 zijn public groepen
$usergroups='0';
$name='';
}
}else{
//name not set.
$usergroup='0'; // 0 zijn public groepen
$usergroups='0';
$name='';
}
}else{
//userid not set.
$usergroup='0'; // 0 zijn public groepen
$usergroups='0';
$name='';
}
?>
Navigation:
[Reply to this message]
|