Re: [PHP] PhP 4.2.1 (and various)

2002-05-15 Thread Olav Bringedal

 --- Analysis & Solutions
<[EMAIL PROTECTED]> wrote: > Olav:

> Perhaps because you're ignoring what I said.
 
> This will generate an error message if there's no
> player variable in the 
> request string and you have error reporting set high
> enough.  Evaluate 
> for "empty($_GET['player'])"
> 
> 
> 
> Why are you testing for playername again?  You
> already know it's there 
> because your'e in the else after the "if
> (!$playername)" statement.
> 
> 
> Hmm...  You're sticking playername into the Session
> array.  I haven't
> used PHP's session handling, but some things seem
> odd here.  Where did
> you start the session?  Also, how is your relocated
> page going to know 
> about the session?  I don't see any code here that
> performs those tasks.
> 
> Enjoy,
> 
> --Dan
> 
> -- 


>From the manual:
With $_SESSION or  $HTTP_SESSION_VARS, there is no
need to use
session_register()/session_unregister()/session_is_registered()
functions. Users can access session variable like a
normal variable. 

I'm pretty sure the sessioning works perfectly. And it
is not the problem. The problem is Header(), which
fails without any error or other output. You can only
look at the other mails posted on this subject, that
it is a major problem in v 4.2.1. Until it is solved,
I'll work on something else...

Thanks for your time.


=
Olav Bringedal
jaggu.org

__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PhP 4.2.1 (and various)

2002-05-15 Thread Analysis & Solutions

Olav:

> >   if( empty($Authorized) ) {
> >  header ('Location: http://jaggu.org');
> >   } else {
> >  $user = $Session['user'];
> >   }
> 
> Thanks for the reply, but it didnt help :)

Perhaps because you're ignoring what I said.


> The code is without errors. What I submitted was
> written on the fly to illustrate what i tried to do.
> 
> Here is the actual code...
> 
> $playername=$_GET['player'];

This will generate an error message if there's no player variable in the 
request string and you have error reporting set high enough.  Evaluate 
for "empty($_GET['player'])"


> if (!$playername)
> {
> ..print HTML form code...
> }
> else 
> {
>   if ($playername)

Why are you testing for playername again?  You already know it's there 
because your'e in the else after the "if (!$playername)" statement.

>   {
>   $_SESSION['playername']=$playername;
>   
>   header('Location:
> http://'.$_SERVER['HTTP_HOST'].'/UTGE/index.html'); 

Hmm...  You're sticking playername into the Session array.  I haven't
used PHP's session handling, but some things seem odd here.  Where did
you start the session?  Also, how is your relocated page going to know 
about the session?  I don't see any code here that performs those tasks.

Enjoy,

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PhP 4.2.1 (and various)

2002-05-15 Thread Olav Bringedal

 --- Analysis & Solutions
<[EMAIL PROTECTED]> wrote: > Olav:
> 
> On Wed, May 15, 2002 at 11:53:06AM +0100, Olav
> Bringedal wrote:
> 
> > $user=$Session["user"];
> > 
> > if(!$Authorized)
> > {
> > header ("Location: http://jaggu.org";);
> > }
> 
> As I was saying before, write your code in a way
> that doesn't generate error
> messages.  For example, the above passage would be
> error free if you did this...
> 
>   if( empty($Authorized) ) {
>  header ('Location: http://jaggu.org');
>   } else {
>  $user = $Session['user'];
>   }
> 
> Enjoy,
> 
> --Dan
> 
> -- 
>PHP classes that make web design
> easier
> SQL Solution  |   Layout Solution   |  Form
> Solution
> sqlsolution.info  | layoutsolution.info | 
> formsolution.info
>  T H E   A N A L Y S I S   A N D   S O L U T I O N S
>   C O M P A N Y
>  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335
> f: 718-854-0409
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

Thanks for the reply, but it didnt help :)

The code is without errors. What I submitted was
written on the fly to illustrate what i tried to do.

Here is the actual code...

$playername=$_GET['player'];
if (!$playername)
{
..print HTML form code...
}
else 
{
if ($playername)
{
$_SESSION['playername']=$playername;

header('Location:
http://'.$_SERVER['HTTP_HOST'].'/UTGE/index.html'); 
}
else
{
die ("something gone wrong! Do it properly");
}   


}

I also tried with ~all in logging and without logging
at all.



=
Olav Bringedal
jaggu.org

__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PhP 4.2.1 (and various)

2002-05-15 Thread Miguel Cruz

On Wed, 15 May 2002, Olav Bringedal wrote:
> That is all well, but if php 4.2.1 interprets any
> output (as errors not only screen errors) as something
> that is sent before a header in a redirect, there is
> no other way (that i'm aware of) around it. 
> 
> Like this:
> 
> $user=$Session["user"];
> if(!$Authorized)
> {
>   header ("Location: http://jaggu.org";);
> }
> this will not work, you have to write:
>  
> @$user=@$Session["user"];
> @if(@!$Authorized)
> {
>   header ("Location: http://jaggu.org";);
> }
> 
> To actually get the redirect. 

That's not new to 4.2.1.

The solution remains the same as always: Choose between either:

A) Using output buffering; or

B) Make sure you don't generate any output before sending headers. You 
don't need to stick @ in front of everything, just eliminate all errors 
from your code and then make sure you aren't printing stuff.

For better or worse, there's no scapegoat here.

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PhP 4.2.1 (and various)

2002-05-15 Thread Analysis & Solutions

Olav:

On Wed, May 15, 2002 at 11:53:06AM +0100, Olav Bringedal wrote:

> $user=$Session["user"];
> 
> if(!$Authorized)
> {
>   header ("Location: http://jaggu.org";);
> }

As I was saying before, write your code in a way that doesn't generate error
messages.  For example, the above passage would be error free if you did this...

  if( empty($Authorized) ) {
 header ('Location: http://jaggu.org');
  } else {
 $user = $Session['user'];
  }

Enjoy,

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PhP 4.2.1 (and various)

2002-05-15 Thread Olav Bringedal

 --- Vincent Oostindie <[EMAIL PROTECTED]>
wrote:
 
> Not only that: if you are running a production
> server, you will probably
> want to log your error messages to a file (or
> syslog, or whatever),
> instead of printing them. So 'display_errors' should
> be off. If that is
> the case, you don't need to use @ anymore, because
> there will be no HTML
> output even in case of problems. The advantage of
> this is that you can
> use the exact same code on a development server
> (with display_errors =
> on) and a production server.
> 
> Vincent
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

That is all well, but if php 4.2.1 interprets any
output (as errors not only screen errors) as something
that is sent before a header in a redirect, there is
no other way (that i'm aware of) around it. 

Like this:

$user=$Session["user"];

if(!$Authorized)
{
header ("Location: http://jaggu.org";);
}
this will not work, you have to write:
 
@$user=@$Session["user"];

@if(@!$Authorized)
{
header ("Location: http://jaggu.org";);
}

To actually get the redirect. 

On http://jaggu.org/info.php, you can see that
display_errors = off

In any case, I think you are onto something. I will
try to narrow down logging, to see if that might be
the problem. 

Thanks for helping!

Olav Bringedal
jaggu.org

__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PhP 4.2.1 (and various)

2002-05-15 Thread Vincent Oostindie

On Wed, 15 May 2002 08:52:49 +0200, Analysis & Solutions wrote:
>> So my question is, why has that changed, and what do we do now to
>> authenticate users and redirect them to anothe page? And what the hell
>> is this "@" thingy, i cant see to find anything on it in the manual,
>> and search doesnt work for chars like that.
> 
> The @ represses error messages.  For example:
>mail('', 'subject', 'body');
> will produce an error message, that the to address is bad, while
>@mail('', 'subject', 'body');
> will silently fail.
> 
> Rather than doing that, it's better to write your code so that there
> won't be error messages in the first place.

Not only that: if you are running a production server, you will probably
want to log your error messages to a file (or syslog, or whatever),
instead of printing them. So 'display_errors' should be off. If that is
the case, you don't need to use @ anymore, because there will be no HTML
output even in case of problems. The advantage of this is that you can
use the exact same code on a development server (with display_errors =
on) and a production server.

Vincent

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PhP 4.2.1 (and various)

2002-05-14 Thread Analysis & Solutions

On Wed, May 15, 2002 at 07:34:13AM +0100, Olav Bringedal wrote:
> 
> First of all my pbpBB 2.0 forums stopped working

Do they use variables straight up, rather than via the new superglobals such as 
$_POST?  Simple solution, change your php.ini to have register_globals = on.


> (http://utge.dyndns.org/phpbb2/index.php). When you
> try to log in i get an error, malfomed header request?

I guess somewhere, some text is being sent out to the browser before the header()  
functions are being called.  Perhaps due to a different level of error reporting in
your new php.ini setup?


> So my question is, why has that changed, and what do
> we do now to authenticate users and redirect them to
> anothe page? And what the hell is this "@" thingy, i
> cant see to find anything on it in the manual, and
> search doesnt work for chars like that.

The @ represses error messages.  For example:
   mail('', 'subject', 'body');
will produce an error message, that the to address is bad, while
   @mail('', 'subject', 'body');
will silently fail.

Rather than doing that, it's better to write your code so that there won't be error
messages in the first place.

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php