Page 1 of 1

XAMPP don't recognizes variables like "PHP_AUTH_USER&qu

PostPosted: 11. November 2008 08:09
by icaroscherma
Hi...
Here the newer XAMPP isn't recognizing some default php variables like "PHP_AUTH_USER", "PHP_AUTH_PW"...
I remember something that in a near past, I had to add some DLLs in httpd.conf (of apache) or was in php.ini (in apache/bin folder)...
Anyone can help me?
Thanks,
Ícaro R. Scherma.

PostPosted: 11. November 2008 13:37
by Wiedmann
Here the newer XAMPP isn't recognizing some default php variables like "PHP_AUTH_USER", "PHP_AUTH_PW"...

You mean $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW']? Well, these are only set after a HTTP authentication.

PostPosted: 11. November 2008 16:16
by icaroscherma
I know, but it HAVE a HTTP Authentication, and it works in my hosting service, but locally it haves a Infinite Looping on LOGIN... I put, and put again, but its like I'm putting the wrong user/pass...
So I've changed "Display Errors" (of php) to "E_ALL" only, so It shows Everything... And after that, It shows that PHP_AUTH_USER, PHP_AUTH_PW are Undefined Variables... So, PHP don't recognizes the user and pass that I input, that was the reason that haves a Infinite Looping xD
I've read in some forums that I need to put "LoadModule php4_module" in Apache, but I've tried some things and no success =x
Please, someone help me T_T

PostPosted: 11. November 2008 16:52
by Nobbie
register_globals ...

(The 1.000.000th request about register_globals).

PostPosted: 11. November 2008 18:27
by Wiedmann
I know

So you are really talking about $_SERVER['PHP_AUTH_USER'] and not $PHP_AUTH_USER?

PostPosted: 11. November 2008 19:27
by icaroscherma
I've tried with "Register Globals" On and Off... And tried with $_SERVER['PHP_AUTH_USER'] and $PHP_AUTH_USER, I'm useing other server, and now, the error its other..

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in F:\wamp\www\opinatorio\senha.php on line 6

<?php
include ("config.php");

$acesso = false;
$user_w = mysql_query("SELECT * FROM usuario");
while($user = mysql_fetch_array($user_w)){

$PHP_AUTH_USER = strtoupper($PHP_AUTH_USER);
$PHP_AUTH_PW = strtolower($PHP_AUTH_PW);

if (($PHP_AUTH_USER == $user['usuario']) && (md5($PHP_AUTH_PW) == $user['usuario_codigo'])){
$user_sw = mysql_query("SELECT * FROM usuario WHERE usuario='$PHP_AUTH_USER' && usuario_codigo='".$user['usuario_codigo']."'");
$user_section = mysql_fetch_array($user_sw);
$sessao = $user_section['nivel'];
$acesso = true;
}
}
if (!$acesso){
header('WWW-Authenticate: Basic Realm="Camaroes Login"');
header('HTTP/1.0 401 Unauthorized');
echo 'Usuario e/ou Senha Invalidos!';
exit;
}
?>


Somebody knows why it's happening that? (The text is in Portuguese Brazilian).
\o\[/quote]

PostPosted: 11. November 2008 19:41
by Wiedmann
And tried with $_SERVER['PHP_AUTH_USER'] and $PHP_AUTH_USER,

Only $_SERVER['PHP_AUTH_USER'] is correct. (There is no guarantee you have $PHP_AUTH_USER on a server).

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in F:\wamp\www\opinatorio\senha.php on line 6

There is a problem with the query on line 5.
--> test the result from mysql_query for an error. And if there is one, use the function mysql_error() to see which one.

PostPosted: 11. November 2008 20:29
by icaroscherma
Wiedmann, how exactly can I do that? xD
\o\

PostPosted: 11. November 2008 21:07
by Wiedmann
--> test the result from mysql_query for an error. And if there is one, use the function mysql_error() to see which one.

how exactly can I do that?

From the PHP manual http://de.php.net/manual/en/function.mysql-query.php (Example 1):
Code: Select all
$user_w = mysql_query("SELECT * FROM usuario");
if (!$user_w) {
    die('Invalid query: ' . mysql_error());
}