php-general Digest 10 Sep 2009 16:21:47 -0000 Issue 6332

Topics (messages 297849 through 297869):

Re: Performance of while(true) loop
        297849 by: Eddie Drapkin
        297850 by: APseudoUtopia
        297851 by: Eddie Drapkin
        297852 by: Ben Dunlap

header problem
        297853 by: A.a.k
        297854 by: George Langley
        297857 by: A.a.k
        297858 by: Marcus Gnaß
        297859 by: Ashley Sheridan
        297860 by: Sándor Tamás (HostWare Kft.)
        297861 by: Ashley Sheridan
        297862 by: Arno Kuhl

upgrade php4 to php5
        297855 by: madunix
        297856 by: Eddie Drapkin

Hoping for a hand with a login script
        297863 by: Watson Blair
        297864 by: Tommy Pham
        297865 by: Tommy Pham
        297866 by: Tony Marston
        297867 by: Watson Blair
        297868 by: Tommy Pham
        297869 by: Ben Dunlap

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
On Wed, Sep 9, 2009 at 10:32 PM, APseudoUtopia <[email protected]> wrote:
> Hey list,
>
> I have a php cli script that listens on a UDP socket and, when data is
> sent to the socket, the script inserts it into a database. I'm using
> the real BSD socket functions, not fsock.
>
> The script runs socket_create(), then socket_bind(). Then it starts a
> while(TRUE) loop. Within the loop, it runs socket_recvfrom(). I have
> it running 24/7 inside a screen window.
>
> I'm curious as to the cpu/memory/etc usage of a while(true) loop. The
> `top` command shows that the process is in the sbwait state (the OS is
> FreeBSD). I'm contemplating adding a usleep or even a sleep inside to
> loop. Would this be beneficial? I'm not too sure of how the internals
> of PHP work in terms of loops and such.
>
> Thanks.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Is your socket blocking?  If so, what's the timeout?

while(true) {

//wait for socket timeout

}

is the same as:

while(true) {

//read nothing from socket and sleep

}

Without the usleep(), the loop is going to loop as fast as your CPU
will let it - meaning 100% CPU usage, all the time, at least in linux,
although I'm pretty sure BSD would behave the same.

As far as I'm aware, sockets in PHP behave almost identically to the
way that they behave in C.  I had an asynchronous TCP server written
with the socket_* functions and noticed that the while(true) loop used
100% of the CPU because of the nonblocking sockets in use, but a
usleep() solved that quite easily.  Using blocking sockets with
socket_select and a sane timeout relieved the high CPU usage as well.

--- End Message ---
--- Begin Message ---
On Wed, Sep 9, 2009 at 10:39 PM, Eddie Drapkin<[email protected]> wrote:
> On Wed, Sep 9, 2009 at 10:32 PM, APseudoUtopia <[email protected]> 
> wrote:
>> Hey list,
>>
>> I have a php cli script that listens on a UDP socket and, when data is
>> sent to the socket, the script inserts it into a database. I'm using
>> the real BSD socket functions, not fsock.
>>
>> The script runs socket_create(), then socket_bind(). Then it starts a
>> while(TRUE) loop. Within the loop, it runs socket_recvfrom(). I have
>> it running 24/7 inside a screen window.
>>
>> I'm curious as to the cpu/memory/etc usage of a while(true) loop. The
>> `top` command shows that the process is in the sbwait state (the OS is
>> FreeBSD). I'm contemplating adding a usleep or even a sleep inside to
>> loop. Would this be beneficial? I'm not too sure of how the internals
>> of PHP work in terms of loops and such.
>>
>> Thanks.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> Is your socket blocking?  If so, what's the timeout?
>
> while(true) {
>
> //wait for socket timeout
>
> }
>
> is the same as:
>
> while(true) {
>
> //read nothing from socket and sleep
>
> }
>
> Without the usleep(), the loop is going to loop as fast as your CPU
> will let it - meaning 100% CPU usage, all the time, at least in linux,
> although I'm pretty sure BSD would behave the same.
>
> As far as I'm aware, sockets in PHP behave almost identically to the
> way that they behave in C.  I had an asynchronous TCP server written
> with the socket_* functions and noticed that the while(true) loop used
> 100% of the CPU because of the nonblocking sockets in use, but a
> usleep() solved that quite easily.  Using blocking sockets with
> socket_select and a sane timeout relieved the high CPU usage as well.
>

I believe it is blocking. Here's my socket_recvfrom:
$Recv = socket_recvfrom($Socket, $Data, 512, MSG_WAITALL, $Name, $Port);

So I think the the MSG_WAITALL is causing it to block until incoming
data connection is closed (it never reaches the 512 byte mark before
it echos the data). Here's the full script, minus the debugging/error
catching stuff:

$Socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$Bind = socket_bind($Socket, '127.0.0.1', 1223);
while(TRUE){
$Recv = socket_recvfrom($Socket, $Data, 512, MSG_WAITALL, $Name, $Port);
print_r($Data);
}

As soon as the message is sent on the socket, it displays it. There's
no delay until it builds up 512 bytes or anything. Also, I was playing
around with ps and it looks like it's using 0% CPU, so I suppose it
must be blocking.

In the case that it is blocking, would it still be wise to throw a
usleep in there just to be sure?

Thanks.

--- End Message ---
--- Begin Message ---
On Wed, Sep 9, 2009 at 10:53 PM, APseudoUtopia <[email protected]> wrote:
> On Wed, Sep 9, 2009 at 10:39 PM, Eddie Drapkin<[email protected]> wrote:
>> On Wed, Sep 9, 2009 at 10:32 PM, APseudoUtopia <[email protected]> 
>> wrote:
>>> Hey list,
>>>
>>> I have a php cli script that listens on a UDP socket and, when data is
>>> sent to the socket, the script inserts it into a database. I'm using
>>> the real BSD socket functions, not fsock.
>>>
>>> The script runs socket_create(), then socket_bind(). Then it starts a
>>> while(TRUE) loop. Within the loop, it runs socket_recvfrom(). I have
>>> it running 24/7 inside a screen window.
>>>
>>> I'm curious as to the cpu/memory/etc usage of a while(true) loop. The
>>> `top` command shows that the process is in the sbwait state (the OS is
>>> FreeBSD). I'm contemplating adding a usleep or even a sleep inside to
>>> loop. Would this be beneficial? I'm not too sure of how the internals
>>> of PHP work in terms of loops and such.
>>>
>>> Thanks.
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> Is your socket blocking?  If so, what's the timeout?
>>
>> while(true) {
>>
>> //wait for socket timeout
>>
>> }
>>
>> is the same as:
>>
>> while(true) {
>>
>> //read nothing from socket and sleep
>>
>> }
>>
>> Without the usleep(), the loop is going to loop as fast as your CPU
>> will let it - meaning 100% CPU usage, all the time, at least in linux,
>> although I'm pretty sure BSD would behave the same.
>>
>> As far as I'm aware, sockets in PHP behave almost identically to the
>> way that they behave in C.  I had an asynchronous TCP server written
>> with the socket_* functions and noticed that the while(true) loop used
>> 100% of the CPU because of the nonblocking sockets in use, but a
>> usleep() solved that quite easily.  Using blocking sockets with
>> socket_select and a sane timeout relieved the high CPU usage as well.
>>
>
> I believe it is blocking. Here's my socket_recvfrom:
> $Recv = socket_recvfrom($Socket, $Data, 512, MSG_WAITALL, $Name, $Port);
>
> So I think the the MSG_WAITALL is causing it to block until incoming
> data connection is closed (it never reaches the 512 byte mark before
> it echos the data). Here's the full script, minus the debugging/error
> catching stuff:
>
> $Socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
> $Bind = socket_bind($Socket, '127.0.0.1', 1223);
> while(TRUE){
> $Recv = socket_recvfrom($Socket, $Data, 512, MSG_WAITALL, $Name, $Port);
> print_r($Data);
> }
>
> As soon as the message is sent on the socket, it displays it. There's
> no delay until it builds up 512 bytes or anything. Also, I was playing
> around with ps and it looks like it's using 0% CPU, so I suppose it
> must be blocking.
>
> In the case that it is blocking, would it still be wise to throw a
> usleep in there just to be sure?
>
> Thanks.
>

MSG_WAITALL will block until 512 bytes of $Data has been received (or
a disconnect), so unless you're receiving a ridiculous amount of data
every iteration, forcing your CPU usage to be very high (which you've
said isn't the case :P) then there's no real reason to sleep every
while iteration.  The reason why you're not getting a delay is because
your "clients" are not maintaining an open connection to the socket,
so it'll output as soon as the remote client disconnects from your
"server".

I wouldn't necessarily say it's unwise or wise to sleep after every
iteration, but it would depend on what kind of latency you need from
your application, how much data it's receiving, etc. etc.  Another
thing you might want to consider about your design is that function,
as you're using it, blocks until those 512 bytes have been read, so if
a normal "request" (assuming a persistent connection) to your socket
is <512 bytes, it could potentially sit there and wait indefinitely
(not very likely).  As it is, though, your server blocks (or sleeps,
if you will) on the socket until a connection is made and it reads 512
bytes / the client disconnects, which seems to be doing well for your
usage.

The old adage "if it ain't broke, don't fix it" sort of applies here.
Your program idles about at 0% CPU usage most of the time, for now.
Until something changes, I'd leave it alone :)

--- End Message ---
--- Begin Message ---
>>>> I have a php cli script that listens on a UDP socket and, when data is
[8<]
>> So I think the the MSG_WAITALL is causing it to block until incoming
>> data connection is closed (it never reaches the 512 byte mark before
[8<]
> your "clients" are not maintaining an open connection to the socket,
> so it'll output as soon as the remote client disconnects from your
> "server".
[8<]
> if you will) on the socket until a connection is made and it reads 512
> bytes / the client disconnects, which seems to be doing well for your
> usage.

Sorry if I'm missing something obvious, but do the concepts of
"connection", "close", and "disconnect" even apply in this case, since
it's a UDP socket?

Ben

--- End Message ---
--- Begin Message ---
hello
I recentrly uploaded my project from localhost to a hosting and found many errors and warnings which didnt have in local. one of the most annoying one is header('Location xxx'). I have used header to redirect users from pages, and kinda used it alot. i know about the whitespace causing warning, but most of the pages i'm sending users got html and php mixed so i'm confused about how to remove whitespace in a html/php file. the error is :
Warning: Cannot modify header information - headers already sent by ....
here is a simple example, user update page :
    if($valid)
                   {
                       $msg='111';
                       $user->dbupdate();
                        header("Location: /admin/index.php?msg=$msg");

                   }
                   else
                   {
                        foreach($errors as $val)
                           echo '<p id="error">'.$val.'</p>';
                   }

and on admin index i get $msg and display it.
<html>
......
//lots of stuff
  <?php
                  $msg = $_GET['msg'];
                          switch($msg){
                          case '111'       echo '<p> </p>';
                                       break;
                         case '421':...
                   }
?>
//  more html and php

how can i fix this?
--- End Message ---
--- Begin Message --- Hi Blueman. As soon as ANYTHING has been drawn to the browser, you cannot use a header command. So you need to work through all of your code, and ensure that all of your logic that could result in a header call is run BEFORE you send any html code. Is going to be tricky if mixing html and php calls.

George


On 10-Sep-09, at 12:27 AM, A.a.k wrote:

hello
I recentrly uploaded my project from localhost to a hosting and found many errors and warnings which didnt have in local. one of the most annoying one is header('Location xxx'). I have used header to redirect users from pages, and kinda used it alot. i know about the whitespace causing warning, but most of the pages i'm sending users got html and php mixed so i'm confused about how to remove whitespace in a html/php file. the error is : Warning: Cannot modify header information - headers already sent by ....
here is a simple example, user update page :
   if($valid)
                  {
                      $msg='111';
                      $user->dbupdate();
                       header("Location: /admin/index.php?msg=$msg");

                  }
                  else
                  {
                       foreach($errors as $val)
                          echo '<p id="error">'.$val.'</p>';
                  }

and on admin index i get $msg and display it.
<html>
......
//lots of stuff
 <?php
                 $msg = $_GET['msg'];
                         switch($msg){
                         case '111'       echo '<p> </p>';
                                      break;
                        case '421':...
                  }
?>
//  more html and php

how can i fix this?

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



--- End Message ---
--- Begin Message ---
is there any alternative to header() for redirect users?

"George Langley" <[email protected]> wrote in message news:[email protected]...
Hi Blueman. As soon as ANYTHING has been drawn to the browser, you cannot use a header command. So you need to work through all of your code, and ensure that all of your logic that could result in a header call is run BEFORE you send any html code. Is going to be tricky if mixing html and php calls.

George


On 10-Sep-09, at 12:27 AM, A.a.k wrote:

hello
I recentrly uploaded my project from localhost to a hosting and found many errors and warnings which didnt have in local. one of the most annoying one is header('Location xxx'). I have used header to redirect users from pages, and kinda used it alot. i know about the whitespace causing warning, but most of the pages i'm sending users got html and php mixed so i'm confused about how to remove whitespace in a html/php file. the error is :
Warning: Cannot modify header information - headers already sent  by ....
here is a simple example, user update page :
   if($valid)
                  {
                      $msg='111';
                      $user->dbupdate();
                       header("Location: /admin/index.php?msg=$msg");

                  }
                  else
                  {
                       foreach($errors as $val)
                          echo '<p id="error">'.$val.'</p>';
                  }

and on admin index i get $msg and display it.
<html>
......
//lots of stuff
 <?php
                 $msg = $_GET['msg'];
                         switch($msg){
                         case '111'       echo '<p> </p>';
                                      break;
                        case '421':...
                  }
?>
//  more html and php

how can i fix this?

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




--- End Message ---
--- Begin Message ---
A.a.k wrote:
> is there any alternative to header() for redirect users?

As far as I know there isn't.

Is the header-error the first error on the page? If not, the other error
message itself is the reason for the header-error and will be solved if
you solve the other error.

--- End Message ---
--- Begin Message ---
On Thu, 2009-09-10 at 08:57 +0200, A.a.k wrote:
> is there any alternative to header() for redirect users?
> 
> "George Langley" <[email protected]> wrote in message 
> news:[email protected]...
> > Hi Blueman. As soon as ANYTHING has been drawn to the browser, you  cannot 
> > use a header command. So you need to work through all of your  code, and 
> > ensure that all of your logic that could result in a header  call is run 
> > BEFORE you send any html code. Is going to be tricky if  mixing html and 
> > php calls.
> >
> > George
> >
> >
> > On 10-Sep-09, at 12:27 AM, A.a.k wrote:
> >
> >> hello
> >> I recentrly uploaded my project from localhost to a hosting and  found 
> >> many errors and warnings which didnt have in local. one of the  most 
> >> annoying one is header('Location xxx').
> >> I have used header to redirect users from pages, and kinda used it  alot. 
> >> i know about the whitespace causing warning, but most of the  pages i'm 
> >> sending users got html and php mixed so i'm confused about  how to remove 
> >> whitespace in a html/php file. the error is :
> >> Warning: Cannot modify header information - headers already sent  by ....
> >> here is a simple example, user update page :
> >>    if($valid)
> >>                   {
> >>                       $msg='111';
> >>                       $user->dbupdate();
> >>                        header("Location: /admin/index.php?msg=$msg");
> >>
> >>                   }
> >>                   else
> >>                   {
> >>                        foreach($errors as $val)
> >>                           echo '<p id="error">'.$val.'</p>';
> >>                   }
> >>
> >> and on admin index i get $msg and display it.
> >> <html>
> >> ......
> >> //lots of stuff
> >>  <?php
> >>                  $msg = $_GET['msg'];
> >>                          switch($msg){
> >>                          case '111'       echo '<p> </p>';
> >>                                       break;
> >>                         case '421':...
> >>                   }
> >> ?>
> >> //  more html and php
> >>
> >> how can i fix this?
> >>
> >> -- 
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> > 
> 
> 

Several:

      * Javascript - not always available on your target system, or
        blocked by script blocking plugins
      * Meta refresh tags - should be honored by the user agent, but may
        not always be.

The problem you have is not that you need to work around this 'problem'
in PHP, but you need to fix your broken code. This problem often comes
up on the list, and is usually because of extra whitespace in include
files, or errors being output to the browser which force the headers to
be sent.

Thanks,
Ash
http://www.ashleysheridan.co.uk




--- End Message ---
--- Begin Message --- Usually, when I have to redirect the user AFTER headers has been sent (like showing an error message), I write this:

<SCRIPT>location=page_to_send.html</SCRIPT>

But this will redirect the user at once. If you want the user to read the page, you should do something in Javascript with setTimeout(func,timeout) function.

BR,
SanTa

----- Original Message ----- From: "George Langley" <[email protected]>
To: <[email protected]>
Sent: Thursday, September 10, 2009 8:39 AM
Subject: Re: [PHP] header problem


Hi Blueman. As soon as ANYTHING has been drawn to the browser, you cannot use a header command. So you need to work through all of your code, and ensure that all of your logic that could result in a header call is run BEFORE you send any html code. Is going to be tricky if mixing html and php calls.

George


On 10-Sep-09, at 12:27 AM, A.a.k wrote:

hello
I recentrly uploaded my project from localhost to a hosting and found many errors and warnings which didnt have in local. one of the most annoying one is header('Location xxx'). I have used header to redirect users from pages, and kinda used it alot. i know about the whitespace causing warning, but most of the pages i'm sending users got html and php mixed so i'm confused about how to remove whitespace in a html/php file. the error is :
Warning: Cannot modify header information - headers already sent  by ....
here is a simple example, user update page :
   if($valid)
                  {
                      $msg='111';
                      $user->dbupdate();
                       header("Location: /admin/index.php?msg=$msg");

                  }
                  else
                  {
                       foreach($errors as $val)
                          echo '<p id="error">'.$val.'</p>';
                  }

and on admin index i get $msg and display it.
<html>
......
//lots of stuff
 <?php
                 $msg = $_GET['msg'];
                         switch($msg){
                         case '111'       echo '<p> </p>';
                                      break;
                        case '421':...
                  }
?>
//  more html and php

how can i fix this?

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



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



--- End Message ---
--- Begin Message ---
On Thu, 2009-09-10 at 09:04 +0200, Sándor Tamás (HostWare Kft.) wrote:
> Usually, when I have to redirect the user AFTER headers has been sent (like 
> showing an error message), I write this:
> 
> <SCRIPT>location=page_to_send.html</SCRIPT>
> 
> But this will redirect the user at once. If you want the user to read the 
> page, you should do something in Javascript with setTimeout(func,timeout) 
> function.
> 
> BR,
> SanTa
> 
> ----- Original Message ----- 
> From: "George Langley" <[email protected]>
> To: <[email protected]>
> Sent: Thursday, September 10, 2009 8:39 AM
> Subject: Re: [PHP] header problem
> 
> 
> > Hi Blueman. As soon as ANYTHING has been drawn to the browser, you  cannot 
> > use a header command. So you need to work through all of your  code, and 
> > ensure that all of your logic that could result in a header  call is run 
> > BEFORE you send any html code. Is going to be tricky if  mixing html and 
> > php calls.
> >
> > George
> >
> >
> > On 10-Sep-09, at 12:27 AM, A.a.k wrote:
> >
> >> hello
> >> I recentrly uploaded my project from localhost to a hosting and  found 
> >> many errors and warnings which didnt have in local. one of the  most 
> >> annoying one is header('Location xxx').
> >> I have used header to redirect users from pages, and kinda used it  alot. 
> >> i know about the whitespace causing warning, but most of the  pages i'm 
> >> sending users got html and php mixed so i'm confused about  how to remove 
> >> whitespace in a html/php file. the error is :
> >> Warning: Cannot modify header information - headers already sent  by ....
> >> here is a simple example, user update page :
> >>    if($valid)
> >>                   {
> >>                       $msg='111';
> >>                       $user->dbupdate();
> >>                        header("Location: /admin/index.php?msg=$msg");
> >>
> >>                   }
> >>                   else
> >>                   {
> >>                        foreach($errors as $val)
> >>                           echo '<p id="error">'.$val.'</p>';
> >>                   }
> >>
> >> and on admin index i get $msg and display it.
> >> <html>
> >> ......
> >> //lots of stuff
> >>  <?php
> >>                  $msg = $_GET['msg'];
> >>                          switch($msg){
> >>                          case '111'       echo '<p> </p>';
> >>                                       break;
> >>                         case '421':...
> >>                   }
> >> ?>
> >> //  more html and php
> >>
> >> how can i fix this?
> >>
> >> -- 
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >
> >
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> > 
> 
> 
Don't use a timer to redirect if you want the user to read a message, as
this assumes that the visitor is a good reader. This is forgetting all
of those visitors with reading difficulties (i.e. Dyslexia), those users
who have attention problems who can't focus on text for long periods
(i.e. ADHD) and any users who rely on things such as screen readers
(which are slower than reading text yourself (if you're an average
reader!) ) or a Braille browser.

In cases such as these, it's best to let the visitor move at their own
pace and not redirect until they want to.

Thanks,
Ash
http://www.ashleysheridan.co.uk




--- End Message ---
--- Begin Message ---
-----Original Message-----
From: A.a.k [mailto:[email protected]] 
Sent: 10 September 2009 08:27 AM
To: [email protected]
Subject: [PHP] header problem

hello
I recentrly uploaded my project from localhost to a hosting and found many
errors and warnings which didnt have in local. one of the most annoying one
is header('Location xxx').
I have used header to redirect users from pages, and kinda used it alot. i
know about the whitespace causing warning, but most of the pages i'm sending
users got html and php mixed so i'm confused about how to remove whitespace
in a html/php file. the error is :
Warning: Cannot modify header information - headers already sent by ....
here is a simple example, user update page :
     if($valid)
                    {
                        $msg='111';
                        $user->dbupdate();
                         header("Location: /admin/index.php?msg=$msg");

                    }
                    else
                    {
                         foreach($errors as $val)
                            echo '<p id="error">'.$val.'</p>';
                    }

and on admin index i get $msg and display it.
<html>
......
//lots of stuff
   <?php
                   $msg = $_GET['msg'];
                           switch($msg){
                           case '111'       echo '<p> </p>';
                                        break;
                          case '421':...
                    }
?>
//  more html and php

how can i fix this? 
--

It's possible that on your localhost you have output_buffering set on either
in php.ini or in a .htaccess, which would avoid the displayed error about
headers. If it's switched on locally and off for your host server then
you'll get the problem you reported. Check that this is off locally (use
phpinfo) so that you can be sure your code is working properly before you
upload.

Alternatively if you want to be able to do a redirect after you've already
started your output (this is sometimes done for error handling) you could
use ob_start() to start output buffering, ob_end_clean() to clear the output
buffer and start again, and ob_flush() to send the output buffer. If you
want to continue using output buffering after an ob_end_clean() you'll have
to do an ob_start() again.

Cheers
Arno


--- End Message ---
--- Begin Message ---
how can i upgrade my php4 to php5?

[r...@intra /]# uname -a
Linux intra 2.6.9-5.ELsmp #1 SMP Wed Jan 5 19:30:39 EST 2005 i686 i686
i386 GNU/Linux
/usr/local/apache/bin/apachectl stop
cd /downloads/
cd php-4.4.3
./configure --with-apxs2=/usr/local/apache/bin/apxs
--with-mysql=/usr/local/mysql --with-zlib-dir=/usr/lib/
--enable-versioning --enable-track-vars=yes
--enable-url-includes--enable-sysvshm=yes --enable-sysvsem=yes
--with-gettext --enable-mbstring --enable-ftp --enable-calendar
--with-config-file-path=/etc --with-oci8=$ORACLE_HOME  --enable-soap
--with-gd  --enable-xml --with-xml  --enable-sysvsem --enable-sysvshm
--enable-sysvmsg --with-regex=system --with-png --with-ttf=/usr/lib
--with-freetype=/usr/lib --enable-sigchild --with-openssl --with-iconv
--with-dom
make
make install
/usr/local/apache/bin/apachectl start


what would be the best way to upgrade to php5?
any modification should be done on php.ini?

your input would be really appreciated?

Thanks
-mu

--- End Message ---
--- Begin Message ---
On Thu, Sep 10, 2009 at 2:51 AM, madunix <[email protected]> wrote:
> how can i upgrade my php4 to php5?
>
> [r...@intra /]# uname -a
> Linux intra 2.6.9-5.ELsmp #1 SMP Wed Jan 5 19:30:39 EST 2005 i686 i686
> i386 GNU/Linux
> /usr/local/apache/bin/apachectl stop
> cd /downloads/
> cd php-4.4.3
> ./configure --with-apxs2=/usr/local/apache/bin/apxs
> --with-mysql=/usr/local/mysql --with-zlib-dir=/usr/lib/
> --enable-versioning --enable-track-vars=yes
> --enable-url-includes--enable-sysvshm=yes --enable-sysvsem=yes
> --with-gettext --enable-mbstring --enable-ftp --enable-calendar
> --with-config-file-path=/etc --with-oci8=$ORACLE_HOME  --enable-soap
> --with-gd  --enable-xml --with-xml  --enable-sysvsem --enable-sysvshm
> --enable-sysvmsg --with-regex=system --with-png --with-ttf=/usr/lib
> --with-freetype=/usr/lib --enable-sigchild --with-openssl --with-iconv
> --with-dom
> make
> make install
> /usr/local/apache/bin/apachectl start
>
>
> what would be the best way to upgrade to php5?
> any modification should be done on php.ini?
>
> your input would be really appreciated?
>
> Thanks
> -mu
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


This might help:
http://php.net/manual/en/faq.migration5.php

--- End Message ---
--- Begin Message ---
Hey guys,This is a simple issue I'm sure, however I'm having one hell of a
time seeing my way clear of it. I appreciate any support you guys could
throw my way.

So I'm trying to set up a small website that includes a store (
www.rareintaglio.com), i have all of my HTML hammed out and now I'm working
on creating an admin login for the sites owner to input data from a back
end. I have it set up so that he goes to /adminlogin.php, enters his info
and gains access to the back end of the website using Session variables
(valid vs. invalid) however i keep getting this reply when i try to run the
script:

Results: SELECT * FROM adminlog WHARE username = 'gourmet28e' AND password =
'*******'
Query failed: Query was empty
here's the /adminlogin script:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<?php

  session_start ;

?>
<head>
<link rel="stylesheet" type="text/css" href="intaglio.css" />
  <title></title>
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
</head>
<body><center>
<div id="body">
 <div id="header"></div>
 <div id="navbody">
 <div id="nav">
   <ul>
  <li><a href="/index.html">Home</a></li>
  <li><a href="/shop.html">Store</a></li>
  <li><a href="/about.html">About</a></li>
  </ul>
  </div>
</div>
 <div id="cbody">

 <?php

 if ($_SESSION['user'] == invalid)
{
echo 'Invalid Username or Password, please try again';
}
if ($_SESSION['user'] == valid)
{
header ("Location: http://www.rareintaglio.com/member.php";);
}
?>
 <form method="post" action="/session.php">
   <table border="0">
<tr><td>Admin Name: </td></tr>
   <tr><td><input type="text" name="username" size="30" maxlength="20"/>
</td></tr>
<tr><td>Password:</td></tr>
<tr><td><input type="password" name="password" size="30" maxlength="20"/>
 </td></tr>
<tr><td><input type="submit" value="Login" />  </td></tr>
</table>
    </div>
<div id="footer"><p>All Pages and Images Copyright @ 2009, Devour.tv Ltd.
All Rights Reserved</p></div>
</body>
</html>


and /session.php goes a little like:
<?php
$host="Rareintag.db.4159106.hostedresource.com"; // Host name
$username="Rareintag"; // Mysql username
$password="**********"; // Mysql password
$db_name="Rareintag"; // Database name
$tbl_name="adminlog"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// username and password sent from form
$username=$_POST['username'];
$password=$_POST['password'];
$qury = "SELECT * FROM adminlog WHARE username = '$username' AND password =
'$password'";
echo '<br />';
echo "Query: " . $query;
echo '<br />';
echo "Results: " . $result;
echo $qury;
echo '<br />';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

if($result == 0){
$_SESSION['user'] = invalid ;
header("Location: http://www.rareintaglio.com/adminlogin.php";);
}
else
{
$_SESSION['user'] = valid  ;
header("Location: http://www.rareintaglio.com/members.php";);
}
?>

However as I mentioned above i keep getting an error,
does anyone know where I took a wrong turn?
Thanks,
Watson

--- End Message ---
--- Begin Message ---
--- On Thu, 9/10/09, Watson Blair <[email protected]> wrote:

> From: Watson Blair <[email protected]>
> Subject: [PHP] Hoping for a hand with a login script
> To: [email protected]
> Date: Thursday, September 10, 2009, 4:06 AM
> Hey guys,This is a simple issue I'm
> sure, however I'm having one hell of a
> time seeing my way clear of it. I appreciate any support
> you guys could
> throw my way.
> 
> So I'm trying to set up a small website that includes a
> store (
> www.rareintaglio.com), i have all of my HTML hammed out and
> now I'm working
> on creating an admin login for the sites owner to input
> data from a back
> end. I have it set up so that he goes to /adminlogin.php,
> enters his info
> and gains access to the back end of the website using
> Session variables
> (valid vs. invalid) however i keep getting this reply when
> i try to run the
> script:
> 
> Results: SELECT * FROM adminlog WHARE username =
> 'gourmet28e' AND password =
> '*******'
> Query failed: Query was empty
> here's the /adminlogin script:
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
> Transitional//EN">
> <html>
> <?php
> 
>   session_start ;
> 
> ?>
> <head>
> <link rel="stylesheet" type="text/css"
> href="intaglio.css" />
>   <title></title>
>   <meta http-equiv="content-type"
> content="text/html;charset=UTF-8" />
> </head>
> <body><center>
> <div id="body">
>  <div id="header"></div>
>  <div id="navbody">
>  <div id="nav">
>    <ul>
>   <li><a
> href="/index.html">Home</a></li>
>   <li><a
> href="/shop.html">Store</a></li>
>   <li><a
> href="/about.html">About</a></li>
>   </ul>
>   </div>
> </div>
>  <div id="cbody">
> 
>  <?php
> 
>  if ($_SESSION['user'] == invalid)
> {
> echo 'Invalid Username or Password, please try again';
> }
> if ($_SESSION['user'] == valid)
> {
> header ("Location: http://www.rareintaglio.com/member.php";);
> }
> ?>
>  <form method="post" action="/session.php">
>    <table border="0">
> <tr><td>Admin Name: </td></tr>
>    <tr><td><input type="text"
> name="username" size="30" maxlength="20"/>
> </td></tr>
> <tr><td>Password:</td></tr>
> <tr><td><input type="password"
> name="password" size="30" maxlength="20"/>
>  </td></tr>
> <tr><td><input type="submit" value="Login"
> />  </td></tr>
> </table>
>     </div>
> <div id="footer"><p>All Pages and Images
> Copyright @ 2009, Devour.tv Ltd.
> All Rights Reserved</p></div>
> </body>
> </html>
> 
> 
> and /session.php goes a little like:
> <?php
> $host="Rareintag.db.4159106.hostedresource.com"; // Host
> name
> $username="Rareintag"; // Mysql username
> $password="**********"; // Mysql password
> $db_name="Rareintag"; // Database name
> $tbl_name="adminlog"; // Table name
> 
> // Connect to server and select databse.
> mysql_connect("$host", "$username", "$password")or
> die("cannot connect");
> mysql_select_db("$db_name")or die("cannot select DB");
> 

You need to read the manual more carefully.
http://www.php.net/manual/en/function.mysql-connect.php


> // username and password sent from form
> $username=$_POST['username'];
> $password=$_POST['password'];
> $qury = "SELECT * FROM adminlog WHARE username =
> '$username' AND password =
> '$password'";
> echo '<br />';
> echo "Query: " . $query;
> echo '<br />';
> echo "Results: " . $result;

http://www.php.net/manual/en/function.mysql-query.php

> echo $qury;
> echo '<br />';
> $result = mysql_query($query) or die('Query failed: ' .
> mysql_error());
> 
> if($result == 0){
> $_SESSION['user'] = invalid ;
> header("Location: http://www.rareintaglio.com/adminlogin.php";);
> }
> else
> {
> $_SESSION['user'] = valid  ;
> header("Location: http://www.rareintaglio.com/members.php";);
> }
> ?>
> 
> However as I mentioned above i keep getting an error,
> does anyone know where I took a wrong turn?
> Thanks,
> Watson
>

--- End Message ---
--- Begin Message ---
--- On Thu, 9/10/09, Tommy Pham <[email protected]> wrote:

> From: Tommy Pham <[email protected]>
> Subject: Re: [PHP] Hoping for a hand with a login script
> To: [email protected]
> Date: Thursday, September 10, 2009, 4:13 AM
> --- On Thu, 9/10/09, Watson Blair
> <[email protected]>
> wrote:
> 
> > From: Watson Blair <[email protected]>
> > Subject: [PHP] Hoping for a hand with a login script
> > To: [email protected]
> > Date: Thursday, September 10, 2009, 4:06 AM
> > Hey guys,This is a simple issue I'm
> > sure, however I'm having one hell of a
> > time seeing my way clear of it. I appreciate any
> support
> > you guys could
> > throw my way.
> > 
> > So I'm trying to set up a small website that includes
> a
> > store (
> > www.rareintaglio.com), i have all of my HTML hammed
> out and
> > now I'm working
> > on creating an admin login for the sites owner to
> input
> > data from a back
> > end. I have it set up so that he goes to
> /adminlogin.php,
> > enters his info
> > and gains access to the back end of the website using
> > Session variables
> > (valid vs. invalid) however i keep getting this reply
> when
> > i try to run the
> > script:
> > 
> > Results: SELECT * FROM adminlog WHARE username =
> > 'gourmet28e' AND password =
> > '*******'
> > Query failed: Query was empty
> > here's the /adminlogin script:
> > 
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
> > Transitional//EN">
> > <html>
> > <?php
> > 
> >   session_start ;
> > 
> > ?>
> > <head>
> > <link rel="stylesheet" type="text/css"
> > href="intaglio.css" />
> >   <title></title>
> >   <meta http-equiv="content-type"
> > content="text/html;charset=UTF-8" />
> > </head>
> > <body><center>
> > <div id="body">
> >  <div id="header"></div>
> >  <div id="navbody">
> >  <div id="nav">
> >    <ul>
> >   <li><a
> > href="/index.html">Home</a></li>
> >   <li><a
> > href="/shop.html">Store</a></li>
> >   <li><a
> > href="/about.html">About</a></li>
> >   </ul>
> >   </div>
> > </div>
> >  <div id="cbody">
> > 
> >  <?php
> > 
> >  if ($_SESSION['user'] == invalid)
> > {
> > echo 'Invalid Username or Password, please try
> again';
> > }
> > if ($_SESSION['user'] == valid)
> > {
> > header ("Location: http://www.rareintaglio.com/member.php";);
> > }
> > ?>
> >  <form method="post"
> action="/session.php">
> >    <table border="0">
> > <tr><td>Admin Name:
> </td></tr>
> >    <tr><td><input type="text"
> > name="username" size="30" maxlength="20"/>
> > </td></tr>
> > <tr><td>Password:</td></tr>
> > <tr><td><input type="password"
> > name="password" size="30" maxlength="20"/>
> >  </td></tr>
> > <tr><td><input type="submit"
> value="Login"
> > />  </td></tr>
> > </table>
> >     </div>
> > <div id="footer"><p>All Pages and Images
> > Copyright @ 2009, Devour.tv Ltd.
> > All Rights Reserved</p></div>
> > </body>
> > </html>
> > 
> > 
> > and /session.php goes a little like:
> > <?php
> > $host="Rareintag.db.4159106.hostedresource.com"; //
> Host
> > name
> > $username="Rareintag"; // Mysql username
> > $password="**********"; // Mysql password
> > $db_name="Rareintag"; // Database name
> > $tbl_name="adminlog"; // Table name
> > 
> > // Connect to server and select databse.
> > mysql_connect("$host", "$username", "$password")or
> > die("cannot connect");
> > mysql_select_db("$db_name")or die("cannot select
> DB");
> > 
> 
> You need to read the manual more carefully.
> http://www.php.net/manual/en/function.mysql-connect.php
> 
> 
> > // username and password sent from form
> > $username=$_POST['username'];
> > $password=$_POST['password'];
> > $qury = "SELECT * FROM adminlog WHARE username =
> > '$username' AND password =
> > '$password'";

You might want to learn the basics of SQL syntax.

> > echo '<br />';
> > echo "Query: " . $query;
> > echo '<br />';
> > echo "Results: " . $result;
> 
> http://www.php.net/manual/en/function.mysql-query.php
> 
> > echo $qury;
> > echo '<br />';
> > $result = mysql_query($query) or die('Query failed: '
> .
> > mysql_error());
> > 
> > if($result == 0){
> > $_SESSION['user'] = invalid ;
> > header("Location: http://www.rareintaglio.com/adminlogin.php";);
> > }
> > else
> > {
> > $_SESSION['user'] = valid  ;
> > header("Location: http://www.rareintaglio.com/members.php";);
> > }
> > ?>
> > 
> > However as I mentioned above i keep getting an error,
> > does anyone know where I took a wrong turn?
> > Thanks,
> > Watson
> >
>

--- End Message ---
--- Begin Message ---
You are constructing your query in "$qury" yet you are trying to read it 
from "$query". Because they have different spellings they are treated as 
different variables.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org


"Watson Blair" <[email protected]> wrote in message 
news:[email protected]...
> Hey guys,This is a simple issue I'm sure, however I'm having one hell of a
> time seeing my way clear of it. I appreciate any support you guys could
> throw my way.
>
> So I'm trying to set up a small website that includes a store (
> www.rareintaglio.com), i have all of my HTML hammed out and now I'm 
> working
> on creating an admin login for the sites owner to input data from a back
> end. I have it set up so that he goes to /adminlogin.php, enters his info
> and gains access to the back end of the website using Session variables
> (valid vs. invalid) however i keep getting this reply when i try to run 
> the
> script:
>
> Results: SELECT * FROM adminlog WHARE username = 'gourmet28e' AND password 
> =
> '*******'
> Query failed: Query was empty
> here's the /adminlogin script:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> <?php
>
>  session_start ;
>
> ?>
> <head>
> <link rel="stylesheet" type="text/css" href="intaglio.css" />
>  <title></title>
>  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
> </head>
> <body><center>
> <div id="body">
> <div id="header"></div>
> <div id="navbody">
> <div id="nav">
>   <ul>
>  <li><a href="/index.html">Home</a></li>
>  <li><a href="/shop.html">Store</a></li>
>  <li><a href="/about.html">About</a></li>
>  </ul>
>  </div>
> </div>
> <div id="cbody">
>
> <?php
>
> if ($_SESSION['user'] == invalid)
> {
> echo 'Invalid Username or Password, please try again';
> }
> if ($_SESSION['user'] == valid)
> {
> header ("Location: http://www.rareintaglio.com/member.php";);
> }
> ?>
> <form method="post" action="/session.php">
>   <table border="0">
> <tr><td>Admin Name: </td></tr>
>   <tr><td><input type="text" name="username" size="30" maxlength="20"/>
> </td></tr>
> <tr><td>Password:</td></tr>
> <tr><td><input type="password" name="password" size="30" maxlength="20"/>
> </td></tr>
> <tr><td><input type="submit" value="Login" />  </td></tr>
> </table>
>    </div>
> <div id="footer"><p>All Pages and Images Copyright @ 2009, Devour.tv Ltd.
> All Rights Reserved</p></div>
> </body>
> </html>
>
>
> and /session.php goes a little like:
> <?php
> $host="Rareintag.db.4159106.hostedresource.com"; // Host name
> $username="Rareintag"; // Mysql username
> $password="**********"; // Mysql password
> $db_name="Rareintag"; // Database name
> $tbl_name="adminlog"; // Table name
>
> // Connect to server and select databse.
> mysql_connect("$host", "$username", "$password")or die("cannot connect");
> mysql_select_db("$db_name")or die("cannot select DB");
>
> // username and password sent from form
> $username=$_POST['username'];
> $password=$_POST['password'];
> $qury = "SELECT * FROM adminlog WHARE username = '$username' AND password 
> =
> '$password'";
> echo '<br />';
> echo "Query: " . $query;
> echo '<br />';
> echo "Results: " . $result;
> echo $qury;
> echo '<br />';
> $result = mysql_query($query) or die('Query failed: ' . mysql_error());
>
> if($result == 0){
> $_SESSION['user'] = invalid ;
> header("Location: http://www.rareintaglio.com/adminlogin.php";);
> }
> else
> {
> $_SESSION['user'] = valid  ;
> header("Location: http://www.rareintaglio.com/members.php";);
> }
> ?>
>
> However as I mentioned above i keep getting an error,
> does anyone know where I took a wrong turn?
> Thanks,
> Watson
> 



--- End Message ---
--- Begin Message ---
Hey Tommy,Thanks for the link, I found a few typos in my variables, and
Query. but now it's returning:

Results: Resource id #2
*Warning*: Cannot modify header information - headers already sent by
(output started at /home/content/i/n/t/intag/html/session.php:16) in *
/home/content/i/n/t/intag/html/session.php* on line *29*
*
*
*line 29 reads:*
*header("Location: http://www.rareintaglio.com/members.php";);*
*
*
so ya, I'm a little confused... I'm more than willing to do the
reading necessary, could you point me in the correct direction? Ive looked
at a fair amount of documentation on Resources id#2, but I'm having some
trouble making heads or tails of it as it applies to my script.
Thanks for the pointers,
Watson
*
*
*
*

--- End Message ---
--- Begin Message ---
-- On Thu, 9/10/09, Watson Blair <[email protected]> wrote:

> From: Watson Blair <[email protected]>
> Subject: Re: [PHP] Hoping for a hand with a login script
> To: "Tommy Pham" <[email protected]>
> Cc: [email protected]
> Date: Thursday, September 10, 2009, 4:31 AM
> Hey Tommy,Thanks for the link, I found
> a few typos in my variables, and Query. but now it's
> returning:
> Results: Resource id #2
> 
> Warning: Cannot modify header information - headers
> already sent by (output started at
> /home/content/i/n/t/intag/html/session.php:16)
> in /home/content/i/n/t/intag/html/session.php on
> line 29
> 
> line 29
> reads:
> header("Location: http://www.rareintaglio.com/members.php";);
> 
> so ya,
> I'm a little confused... I'm more than willing to do
> the reading necessary, could you point me in the correct
> direction? Ive looked at a fair amount of documentation
> on Resources id#2, but I'm having some trouble making
> heads or tails of it as it applies to my
> script.
> Thanks for the
> pointers,Watson
> 
> 
Read the entire thread of "Include files in HTML":
http://marc.info/?l=php-general&w=2&r=1&s=include+files+in+html&q=b


--- End Message ---
--- Begin Message ---
> So I'm trying to set up a small website that includes a store (
> www.rareintaglio.com), i have all of my HTML hammed out and now I'm working
> on creating an admin login for the sites owner to input data from a back

I would really strongly advise against building your own
authentication system. I'm currently regretting the fact that I did
the same, a few years ago, for a couple of systems I still support.
There are just too many things that can go wrong, especially if you're
new to PHP and MySQL in general. Just to begin with, the code you
posted currently suffers from a really basic SQL injection
vulnerability and your database is likely be compromised within hours
of your site getting any kind of significant traffic. That's
completely distinct from the more basic syntax trouble.

Perhaps paradoxically, the more experience you gain with these things,
the less inclined you will be, most likely, to try to roll your own
AAA.

There are lots of open-source PHP frameworks out there that should be
able to take care of authentication and access-control for you --
CodeIgniter, Zend Framework, and Solar come immediately to mind as
packages that I've either heard good things about, or suspect are
solid because of the authors involved. I'm sure there are several
other good ones also.

http://codeigniter.com/
http://framework.zend.com/
http://www.solarphp.com/

Ben

--- End Message ---

Reply via email to