RE: [PHP] SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS

2009-08-21 Thread Leon du Plessis
Hi Jamie. 

Thanks. Good info. I knew something changed somewhere. This works like a
charm in IE8..never saw the New Session option under file...me bad !!

Greetings.


-Original Message-
From: Jaime Bozza [mailto:jbo...@mindsites.com] 
Sent: 20 August 2009 09:49 PM
To: Leon du Plessis; 'Floyd Resler'
Cc: a...@dotcontent.net; php-general@lists.php.net
Subject: RE: [PHP] SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS

Leon,

This is really just a function of the browser.   When a session cookie is
created, if the browser is setup for a single instance, that's the session
cookie it'll use for *any* request to that domain.  This functions
differently depending on what browser you're using.

For example:
Firefox - All windows, tabs, etc, under the same profile will use the same
session.   If you create profiles, you can have different sessions.
IE7, IE6 - All tabs or windows opened from clicks will share the same
instance/session.  Starting IE from the icon will open up a new
instance/session.  This worked great if you wanted to run two different
sessions at the same site/domain.  Just start IE up from the icon again and
you'd have a new session.
IE8 - IE8 model changed, so that all browser windows, tabs, etc., run under
the same frame/session, much like Firefox.  Clicking the IE icon again now
just keeps the same frame and thus the same session.  Originally, this
sounded like a big problem, but IE8 introduced a new feature - File Menu -
New Session.   This will open up a new window that will be a separate frame
that will not use current session cookies.

Here's just one of many links, but gives some helpful hints on the IE side:
http://blogs.msdn.com/ie/archive/2009/05/06/session-cookies-sessionstorage-a
nd-ie8.aspx

And another:
http://blogs.msdn.com/askie/archive/2009/05/08/session-management-within-int
ernet-explorer-8-0.aspx

One of the issues now is that if you close IE, your session does not
disappear.  In the past (IE7/IE6), your session would disappear if you
closed a browser window that you opened yourself, but it *wouldn't*
disappear if you closed a browser window that was opened by a click from
Outlook or another program.  This was a bit inconsistent.  I won't argue
whether or not their fix was the best way to go, but now it's at least
consistent.

Note - In Firefox, not even Private Browsing separates the session
cookies.  If you start Private Browsing (Firefox 3.5), log into a site, then
start a new browser window from the icon (that isn't in Private Browsing
mode), it shares the session cookies. (Before you ask, I just checked this
to be sure.)

IE8 InPrivate Mode is a totally separate session, cookies and all.  This
could possibly be another way for you to run multiple sessions against the
same domain.  OTOH, multiple InPrivate sessions running at the same time
share the same frame, so they share the same session, so it would only be
good for a single new session.  If you need more, just use File - New
Session.

Jaime 


 -Original Message-
 From: Leon du Plessis [mailto:l...@dsgnit.com]
 Sent: Thursday, August 20, 2009 8:16 AM
 To: 'Floyd Resler'
 Cc: a...@dotcontent.net; php-general@lists.php.net
 Subject: [PHP] SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS
 
 It is just strange that I have this condition now...maybe I missed it
 a
 year ago ?
 
  Having a different session start up for each window for tab would
 be a
 major pain.
 
 Why?
 
 People must please try and understand what I mean by NEW. It does not
 apply
 to windows/tabs being opened from a link or request.
 
 Imho, keeping the session per domain sounds wrong, it does not mean
 it is.
 It would have been nice if:
 
 Browser/tab one - my login detail container A.
 Browser/tab two - my admin login container B.
 (tabs/windows opened from browser one, then inherits container A
 naturally)
 (Closing browser one, then destroys container A then naturally only)
 
 NOT
 
 Domain.com - one session container only.
 
 Heck, I am surprised it works that way at all cause it sounds like
 the
 domain can then only handle one user a time if arrays are not used or
 profiles not created on FF no matter where the request come from, but,
 then
 I am obviously missing something in this respect as stated. When I have
 time
 I will reconstruct this concept again.
 
 Thanks anyway guys. I received some helpful advise for future
 reference.
 
 But please..I do not, like many others, want to start a war. I am ok
 with
 things how they are. We can put this thing to rest.
 
 -Original Message-
 From: Floyd Resler [mailto:fres...@adex-intl.com]
 Sent: 20 August 2009 02:25 PM
 To: Leon du Plessis
 Cc: a...@dotcontent.net; php-general@lists.php.net
 Subject: Re: [PHP] SESSIONS lost sometimes
 
 Leon,
   Sessions are used on a per-domain basis.  So, no matter how many
 windows or tabs you have open for mydomain.com it will be the same
 session for all.  Having a different session start up for each window
 or tab would be a major

RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Leon du Plessis

Since we are on the subject: I have the following similar problem:

When testing page on internet explorer, I find that one tab's variables can
affect another tab's variables. Thus when having the same web-site open and
using SESSION variables but for different users, Internet explorer can
become disorientated. This also sometimes happen when I have two
separate browsing windows open with Internet Explorer for the same site.

I have yet to determine if this is an internet explorer, or PHP or
combination of the two that is causing this condition. 

To my understanding _SESSION variables should be maintained per session, tab
or window. If this has been addressed already, my apologies, but thought it
worthwhile to mention.  

If someone perhaps have a solution or can confirm this as a known issue and
maybe is the same or related to Angelo's problem?


-Original Message-
From: Angelo Zanetti [mailto:ang...@zlogic.co.za] 
Sent: 20 August 2009 08:53 AM
To: 'Ben Dunlap'
Cc: php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes



-Original Message-
From: Ben Dunlap [mailto:bdun...@agentintellect.com] 
Sent: 19 August 2009 08:18 PM
To: Angelo Zanetti
Cc: php-general@lists.php.net
Subject: Re: [PHP] SESSIONS lost sometimes

 We have a server with a site that does some XML calls. After lots of
testing
 I have found that the server is losing session variables.
[8]
 Also the site goes from HTTP to HTTPS at some point but this isn't the
issue
 as it loses the sessions as soon as they are set sometimes.

 Therefore I would like to know what I could check. I have read in other

Can you clarify what you mean by losing sessions? Have you taken a
network trace to see whether the client is consistently sending the
session ID with every request?

When the problem happens, is $_SESSION completely empty or is it only
missing some variables? Does it seem to happen on any page, or only
certain ones?

Thanks,

Ben


Hi Ben, 

When the problem happens the $_SESSION is partially empty. It only has the
some of the variables set.

It happens on a certain page only, but the strange thing is that it never
happened before its only happening now. But the code hasn't changed so is it
safe to assume that it's a server issue?

Thanks
Angelo

-- 
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


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



RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Leon du Plessis
 It's not an issue, it's a feature.

Thanks Arno...but it is a pain also.
If I work with user A in Tab1 (window1), I want to work with user B
separately in Tab2. When user in Tab2 logs off, I still want user A to work,
and not suddenly have to re-login. Same with bank. If I work with my company
account, then my personal account must not become an issue because I am on
the same machine and site. 

I have no issue with using FF and IE to do testing as that takes care of
browser compatibility testing at the same time :-), but I think when you
start a new session with new values, it should be kept under that window/tab
alone. Cookies can take care of more details, but my opinion is data should
never be affected across windows/tabs unless the same user is logged in on
botheven then I would expect PHP to keep data per session. Maybe it goes
beyond being an IE or FF issue..the questiojn is...will PHP allow variables
from session A become corrupted when session B is in progress when they
should actually be handled seperately?

In the end I think it is something I do wrong in PHP with the SESSION
variables and how I clear themif so...I don't think PHP should allow
clearing SESSION variables from other sessions.
 
-Original Message-
From: Arno Kuhl [mailto:ak...@telkomsa.net] 
Sent: 20 August 2009 10:03 AM
To: 'Leon du Plessis'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

-Original Message-
From: Leon du Plessis [mailto:l...@dsgnit.com] 
Sent: 20 August 2009 09:44 AM
To: php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

Since we are on the subject: I have the following similar problem:

When testing page on internet explorer, I find that one tab's variables can
affect another tab's variables. Thus when having the same web-site open and
using SESSION variables but for different users, Internet explorer can
become disorientated. This also sometimes happen when I have two
separate browsing windows open with Internet Explorer for the same site.

I have yet to determine if this is an internet explorer, or PHP or
combination of the two that is causing this condition. 

To my understanding _SESSION variables should be maintained per session, tab
or window. If this has been addressed already, my apologies, but thought it
worthwhile to mention.  

If someone perhaps have a solution or can confirm this as a known issue and
maybe is the same or related to Angelo's problem?



If different browser windows/tabs on the same client-side computer didn't
share session info then you'd get the effect of being able to log onto a
site with one browser window, but find in a second browser window that you
were not yet logged on. Experience will tell you that you're logged on in
both browser windows (try it with your online bank). It's not an issue, it's
a feature. If you want to be able to use different browser windows as though
they were different users then use different browsers e.g. IE and FF on the
same client-side computer will look like two separate end users to the
server, and they don't share session info or cookies.

Cheers
Arno


-- 
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



RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Leon du Plessis
 It'd make sense for things to run this way, I think.  After all, I'd
find it quite confusing if I log into Google Docs, open a document (by
default, it opens in a new tab) and I had to log in yet again to be able to
edit it.

Yes. I agree. But in this case the Tab being opened is used with the same
authentication details either via POST, GET or Cookie variables. The problem
comes in when a totally different set of login credentials are being used
(for the same tab/window).  Other user's login particulars should not affect
your login variables.

-Original Message-
From: Nitebirdz [mailto:nitebi...@sacredchaos.com] 
Sent: 20 August 2009 10:40 AM
To: php-general@lists.php.net
Subject: Re: [PHP] SESSIONS lost sometimes

On Thu, Aug 20, 2009 at 09:44:02AM +0200, Leon du Plessis wrote:
 
 Since we are on the subject: I have the following similar problem:
 
 When testing page on internet explorer, I find that one tab's variables
can
 affect another tab's variables. Thus when having the same web-site open
and
 using SESSION variables but for different users, Internet explorer can
 become disorientated. This also sometimes happen when I have two
 separate browsing windows open with Internet Explorer for the same site.
 
 I have yet to determine if this is an internet explorer, or PHP or
 combination of the two that is causing this condition. 
 
 To my understanding _SESSION variables should be maintained per session,
tab
 or window. If this has been addressed already, my apologies, but thought
it
 worthwhile to mention.  
 

I'm a total newbie when it comes to these issues, but it seems to me
that Firefox behaves in the very same manner.  It's not limited to PHP
sessions either.  It's always been my experience on any website that
requires authentication, including the likes of Google Mail, etc.  When
I want to run multiple sessions for different GMail accounts, for
example, I just create a different user profile in Firefox. 

It'd make sense for things to run this way, I think.  After all, I'd
find it quite confusing if I log into Google Docs, open a document (by
default, it opens in a new tab) and I had to log in yet again to be able
to edit it.  


-- 
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



RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Leon du Plessis


That is how I know browsers to work, yet for a while the bahaviour has
changed. The question in light of this then is, should a new browser or tab
not open a new PHP SESSION ID. Session ID's should be kept if called from
existing pages or ID's? But new pages has no parent? Just wondering.

-Original Message-
From: Peter Ford [mailto:p...@justcroft.com] 
Sent: 20 August 2009 10:47 AM
To: php-general@lists.php.net
Subject: Re: [PHP] SESSIONS lost sometimes

Leon du Plessis wrote:
  It's not an issue, it's a feature.
 
 Thanks Arno...but it is a pain also.
 If I work with user A in Tab1 (window1), I want to work with user B
 separately in Tab2. When user in Tab2 logs off, I still want user A to
work,
 and not suddenly have to re-login. Same with bank. If I work with my
company
 account, then my personal account must not become an issue because I am on
 the same machine and site. 
 
 I have no issue with using FF and IE to do testing as that takes care of
 browser compatibility testing at the same time :-), but I think when you
 start a new session with new values, it should be kept under that
window/tab
 alone. Cookies can take care of more details, but my opinion is data
should
 never be affected across windows/tabs unless the same user is logged in on
 botheven then I would expect PHP to keep data per session. Maybe it
goes
 beyond being an IE or FF issue..the questiojn is...will PHP allow
variables
 from session A become corrupted when session B is in progress when they
 should actually be handled seperately?
 
 In the end I think it is something I do wrong in PHP with the SESSION
 variables and how I clear themif so...I don't think PHP should allow
 clearing SESSION variables from other sessions.
  
 -Original Message-
 From: Arno Kuhl [mailto:ak...@telkomsa.net] 
 Sent: 20 August 2009 10:03 AM
 To: 'Leon du Plessis'; php-general@lists.php.net
 Subject: RE: [PHP] SESSIONS lost sometimes
 
 -Original Message-
 From: Leon du Plessis [mailto:l...@dsgnit.com] 
 Sent: 20 August 2009 09:44 AM
 To: php-general@lists.php.net
 Subject: RE: [PHP] SESSIONS lost sometimes
 
 Since we are on the subject: I have the following similar problem:
 
 When testing page on internet explorer, I find that one tab's variables
can
 affect another tab's variables. Thus when having the same web-site open
and
 using SESSION variables but for different users, Internet explorer can
 become disorientated. This also sometimes happen when I have two
 separate browsing windows open with Internet Explorer for the same site.
 
 I have yet to determine if this is an internet explorer, or PHP or
 combination of the two that is causing this condition. 
 
 To my understanding _SESSION variables should be maintained per session,
tab
 or window. If this has been addressed already, my apologies, but thought
it
 worthwhile to mention.  
 
 If someone perhaps have a solution or can confirm this as a known issue
and
 maybe is the same or related to Angelo's problem?
 
 
 
 If different browser windows/tabs on the same client-side computer didn't
 share session info then you'd get the effect of being able to log onto a
 site with one browser window, but find in a second browser window that you
 were not yet logged on. Experience will tell you that you're logged on in
 both browser windows (try it with your online bank). It's not an issue,
it's
 a feature. If you want to be able to use different browser windows as
though
 they were different users then use different browsers e.g. IE and FF on
the
 same client-side computer will look like two separate end users to the
 server, and they don't share session info or cookies.
 
 Cheers
 Arno
 
 

The key thing is that both tabs (or windows) from the same browser are in
the
*same* session - they send the *same* PHPID cookie. PHP is essentially
stateless
- it doesn't care where the request comes from, and ties a session to the
PHPID
cookie if it gets one. As far as PHP knows, requests from different tabs
with
the same PHPID cookie are requests from the same place in the same session.

To get a different session you need a different instance of the browser -
that's
the way browsers have been coded to work. It's not too hard with Firefox,
since
you can set up multiple profiles to have independent Firefox windows on the
same
screen.

-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

-- 
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



RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Leon du Plessis
Hi, 

Just a re-iteration on the problem:

Browser 1 has user A details 

Browser 2 has user B details

User B logs off, then user A is suddenly in logged of status also.

The method used to destroy the session is:
// Unset all of the session variables.
$_SESSION = array();

// Finally, destroy the session.
session_destroy();

Problem. User's A session is also destroyed. The concern is, that this
should not be the case. User A must happily continue to work.

So, should PHP destroy the whole browser's session id's variables? My answer
is No.

User A and user B should have different session ids, if not, then it is
wrong. A new window should have PHP to spawn a new session id (that is, the
request does not come from an existing page where an id has been created
already. If the ids are different, then session_destroy should only clear
variables for relevant session_id, ie only User B's details In this example.


The problem then probably lies in the session_ids being either the same for
the two different logins (although they are on different browser) or
session_destroy clearing data across sessions. (I will test that later). It
would then seem that session ids is setup per location/machine by MS Windows
as per Peter's explanation. Setting up profiles is the the resolution as
suggested. Otherwise, it would be nice if Windows/IE/FF/PHP could identify
when a BRAND NEW page is being opened and then create a brand new session id
for that window/tab.

It is not a huge issue, I was just wondering if someone else had the same
annoying condition. I am happy with the responses and the functionality
somewhere on a wish-list. 

Now Back to Angelo's SESSION problem which sounded like it could be related.

Greetings!
Leon

-Original Message-
From: Leon du Plessis [mailto:l...@dsgnit.com] 
Sent: 20 August 2009 10:57 AM
To: 'Peter Ford'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes



That is how I know browsers to work, yet for a while the bahaviour has
changed. The question in light of this then is, should a new browser or tab
not open a new PHP SESSION ID. Session ID's should be kept if called from
existing pages or ID's? But new pages has no parent? Just wondering.

-Original Message-
From: Peter Ford [mailto:p...@justcroft.com] 
Sent: 20 August 2009 10:47 AM
To: php-general@lists.php.net
Subject: Re: [PHP] SESSIONS lost sometimes

Leon du Plessis wrote:
  It's not an issue, it's a feature.
 
 Thanks Arno...but it is a pain also.
 If I work with user A in Tab1 (window1), I want to work with user B
 separately in Tab2. When user in Tab2 logs off, I still want user A to
work,
 and not suddenly have to re-login. Same with bank. If I work with my
company
 account, then my personal account must not become an issue because I am on
 the same machine and site. 
 
 I have no issue with using FF and IE to do testing as that takes care of
 browser compatibility testing at the same time :-), but I think when you
 start a new session with new values, it should be kept under that
window/tab
 alone. Cookies can take care of more details, but my opinion is data
should
 never be affected across windows/tabs unless the same user is logged in on
 botheven then I would expect PHP to keep data per session. Maybe it
goes
 beyond being an IE or FF issue..the questiojn is...will PHP allow
variables
 from session A become corrupted when session B is in progress when they
 should actually be handled seperately?
 
 In the end I think it is something I do wrong in PHP with the SESSION
 variables and how I clear themif so...I don't think PHP should allow
 clearing SESSION variables from other sessions.
  
 -Original Message-
 From: Arno Kuhl [mailto:ak...@telkomsa.net] 
 Sent: 20 August 2009 10:03 AM
 To: 'Leon du Plessis'; php-general@lists.php.net
 Subject: RE: [PHP] SESSIONS lost sometimes
 
 -Original Message-
 From: Leon du Plessis [mailto:l...@dsgnit.com] 
 Sent: 20 August 2009 09:44 AM
 To: php-general@lists.php.net
 Subject: RE: [PHP] SESSIONS lost sometimes
 
 Since we are on the subject: I have the following similar problem:
 
 When testing page on internet explorer, I find that one tab's variables
can
 affect another tab's variables. Thus when having the same web-site open
and
 using SESSION variables but for different users, Internet explorer can
 become disorientated. This also sometimes happen when I have two
 separate browsing windows open with Internet Explorer for the same site.
 
 I have yet to determine if this is an internet explorer, or PHP or
 combination of the two that is causing this condition. 
 
 To my understanding _SESSION variables should be maintained per session,
tab
 or window. If this has been addressed already, my apologies, but thought
it
 worthwhile to mention.  
 
 If someone perhaps have a solution or can confirm this as a known issue
and
 maybe is the same or related to Angelo's problem?
 
 
 
 If different browser windows

RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Leon du Plessis
Thanks Ashley, 

I just want to iterate again that when a new page is opened by another
existing page in a new browser or Tab, the session_id is already created and
therefore the current way browsers work is in no way compremised. The new
browser/tab would receive the session id along with GET or POST variables.

What I am suggesting/hoping is that when a new browser is opened or a new
tab is opened via the application, the protocols would reckognize that this
is the first time the page is served and is not being called from another
page. That is, a new page is loaded by the user entering it, and NOT by
clicking login or some other link from an existing page.

Yes, I know..that creates other scenarios, so is happy to not meddle with
the way browsers work. It is just a limitation I will live with and can get
by with it.

Regards
Leon

-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: 20 August 2009 11:39 AM
To: Leon du Plessis
Cc: 'Nitebirdz'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

On Thu, 2009-08-20 at 10:50 +0200, Leon du Plessis wrote:
  It'd make sense for things to run this way, I think.  After all, I'd
 find it quite confusing if I log into Google Docs, open a document (by
 default, it opens in a new tab) and I had to log in yet again to be able
to
 edit it.
 
 Yes. I agree. But in this case the Tab being opened is used with the same
 authentication details either via POST, GET or Cookie variables. The
problem
 comes in when a totally different set of login credentials are being used
 (for the same tab/window).  Other user's login particulars should not
affect
 your login variables.
 
 -Original Message-
 From: Nitebirdz [mailto:nitebi...@sacredchaos.com] 
 Sent: 20 August 2009 10:40 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] SESSIONS lost sometimes
 
 On Thu, Aug 20, 2009 at 09:44:02AM +0200, Leon du Plessis wrote:
  
  Since we are on the subject: I have the following similar problem:
  
  When testing page on internet explorer, I find that one tab's variables
 can
  affect another tab's variables. Thus when having the same web-site open
 and
  using SESSION variables but for different users, Internet explorer can
  become disorientated. This also sometimes happen when I have two
  separate browsing windows open with Internet Explorer for the same site.
  
  I have yet to determine if this is an internet explorer, or PHP or
  combination of the two that is causing this condition. 
  
  To my understanding _SESSION variables should be maintained per session,
 tab
  or window. If this has been addressed already, my apologies, but thought
 it
  worthwhile to mention.  
  
 
 I'm a total newbie when it comes to these issues, but it seems to me
 that Firefox behaves in the very same manner.  It's not limited to PHP
 sessions either.  It's always been my experience on any website that
 requires authentication, including the likes of Google Mail, etc.  When
 I want to run multiple sessions for different GMail accounts, for
 example, I just create a different user profile in Firefox. 
 
 It'd make sense for things to run this way, I think.  After all, I'd
 find it quite confusing if I log into Google Docs, open a document (by
 default, it opens in a new tab) and I had to log in yet again to be able
 to edit it.  
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
The point is you are misunderstanding how browsers work. What the server
app is seeing is a new login that replaces the first. This is the way
browsers work, and if it changed to the idea you have for it, then
millions of sites would suddenly fail to work; i.e. any site that
requires a new tab or window to be opened in order to function, like
banks, etc.

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




-- 
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



RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Leon du Plessis
Thanks Ashley. Will implement if the need arise again..
By limitation I actually meant annoyance. 
Limitation was the wrong word to use.
(I think all browsers has something great and something not so great)

:-)
Greetings

-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: 20 August 2009 12:05 PM
To: Leon du Plessis
Cc: 'Nitebirdz'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

On Thu, 2009-08-20 at 12:04 +0200, Leon du Plessis wrote:
 Thanks Ashley, 
 
 I just want to iterate again that when a new page is opened by another
 existing page in a new browser or Tab, the session_id is already created
and
 therefore the current way browsers work is in no way compremised. The new
 browser/tab would receive the session id along with GET or POST variables.
 
 What I am suggesting/hoping is that when a new browser is opened or a new
 tab is opened via the application, the protocols would reckognize that
this
 is the first time the page is served and is not being called from another
 page. That is, a new page is loaded by the user entering it, and NOT by
 clicking login or some other link from an existing page.
 
 Yes, I know..that creates other scenarios, so is happy to not meddle with
 the way browsers work. It is just a limitation I will live with and can
get
 by with it.
 
 Regards
 Leon
 
 -Original Message-
 From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
 Sent: 20 August 2009 11:39 AM
 To: Leon du Plessis
 Cc: 'Nitebirdz'; php-general@lists.php.net
 Subject: RE: [PHP] SESSIONS lost sometimes
 
 On Thu, 2009-08-20 at 10:50 +0200, Leon du Plessis wrote:
   It'd make sense for things to run this way, I think.  After all, I'd
  find it quite confusing if I log into Google Docs, open a document (by
  default, it opens in a new tab) and I had to log in yet again to be able
 to
  edit it.
  
  Yes. I agree. But in this case the Tab being opened is used with the
same
  authentication details either via POST, GET or Cookie variables. The
 problem
  comes in when a totally different set of login credentials are being
used
  (for the same tab/window).  Other user's login particulars should not
 affect
  your login variables.
  
  -Original Message-
  From: Nitebirdz [mailto:nitebi...@sacredchaos.com] 
  Sent: 20 August 2009 10:40 AM
  To: php-general@lists.php.net
  Subject: Re: [PHP] SESSIONS lost sometimes
  
  On Thu, Aug 20, 2009 at 09:44:02AM +0200, Leon du Plessis wrote:
   
   Since we are on the subject: I have the following similar problem:
   
   When testing page on internet explorer, I find that one tab's
variables
  can
   affect another tab's variables. Thus when having the same web-site
open
  and
   using SESSION variables but for different users, Internet explorer can
   become disorientated. This also sometimes happen when I have two
   separate browsing windows open with Internet Explorer for the same
site.
   
   I have yet to determine if this is an internet explorer, or PHP or
   combination of the two that is causing this condition. 
   
   To my understanding _SESSION variables should be maintained per
session,
  tab
   or window. If this has been addressed already, my apologies, but
thought
  it
   worthwhile to mention.  
   
  
  I'm a total newbie when it comes to these issues, but it seems to me
  that Firefox behaves in the very same manner.  It's not limited to PHP
  sessions either.  It's always been my experience on any website that
  requires authentication, including the likes of Google Mail, etc.  When
  I want to run multiple sessions for different GMail accounts, for
  example, I just create a different user profile in Firefox. 
  
  It'd make sense for things to run this way, I think.  After all, I'd
  find it quite confusing if I log into Google Docs, open a document (by
  default, it opens in a new tab) and I had to log in yet again to be able
  to edit it.  
  
  
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 The point is you are misunderstanding how browsers work. What the server
 app is seeing is a new login that replaces the first. This is the way
 browsers work, and if it changed to the idea you have for it, then
 millions of sites would suddenly fail to work; i.e. any site that
 requires a new tab or window to be opened in order to function, like
 banks, etc.
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 
 
 
 
 -- 
 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
 
There is one way to get around it, and that is to use arrays within your
session variables. So for example, it might look something like this:

$_SESSION['your_app_name']['username']['some_value']

This way, if the username doesn't exist, you know there is no session
for them. It's ugly

RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Leon du Plessis
Hi Angelo, 

No need to be nasty and touchy. If you have done trouble to read I have
closed the discussion in a prior listing and referred back to your original
thread. thanks

-Original Message-
From: Angelo Zanetti [mailto:ang...@zlogic.co.za] 
Sent: 20 August 2009 01:21 PM
To: 'Leon du Plessis'; a...@ashleysheridan.co.uk
Cc: 'Nitebirdz'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

Hi Leon and all.

LEON you are misunderstanding how the sessions work. Also please start your
own thread and don't hijack mine.

To the rest that replied. Thanks, I am still stuck with the problem I have
asked the hosting company to check the storage capacity and also any other
issues with the SESSIONS on the server.

However if anyone has other things they think I can look at, I'd appreciate
that very much.

Thanks
Angelo
http://www.elemental.co.za


-Original Message-
From: Leon du Plessis [mailto:l...@dsgnit.com] 
Sent: 20 August 2009 12:04 PM
To: a...@ashleysheridan.co.uk
Cc: 'Nitebirdz'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

Thanks Ashley, 

I just want to iterate again that when a new page is opened by another
existing page in a new browser or Tab, the session_id is already created and
therefore the current way browsers work is in no way compremised. The new
browser/tab would receive the session id along with GET or POST variables.

What I am suggesting/hoping is that when a new browser is opened or a new
tab is opened via the application, the protocols would reckognize that this
is the first time the page is served and is not being called from another
page. That is, a new page is loaded by the user entering it, and NOT by
clicking login or some other link from an existing page.

Yes, I know..that creates other scenarios, so is happy to not meddle with
the way browsers work. It is just a limitation I will live with and can get
by with it.

Regards
Leon

-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: 20 August 2009 11:39 AM
To: Leon du Plessis
Cc: 'Nitebirdz'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

On Thu, 2009-08-20 at 10:50 +0200, Leon du Plessis wrote:
  It'd make sense for things to run this way, I think.  After all, I'd
 find it quite confusing if I log into Google Docs, open a document (by
 default, it opens in a new tab) and I had to log in yet again to be able
to
 edit it.
 
 Yes. I agree. But in this case the Tab being opened is used with the same
 authentication details either via POST, GET or Cookie variables. The
problem
 comes in when a totally different set of login credentials are being used
 (for the same tab/window).  Other user's login particulars should not
affect
 your login variables.
 
 -Original Message-
 From: Nitebirdz [mailto:nitebi...@sacredchaos.com] 
 Sent: 20 August 2009 10:40 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] SESSIONS lost sometimes
 
 On Thu, Aug 20, 2009 at 09:44:02AM +0200, Leon du Plessis wrote:
  
  Since we are on the subject: I have the following similar problem:
  
  When testing page on internet explorer, I find that one tab's variables
 can
  affect another tab's variables. Thus when having the same web-site open
 and
  using SESSION variables but for different users, Internet explorer can
  become disorientated. This also sometimes happen when I have two
  separate browsing windows open with Internet Explorer for the same site.
  
  I have yet to determine if this is an internet explorer, or PHP or
  combination of the two that is causing this condition. 
  
  To my understanding _SESSION variables should be maintained per session,
 tab
  or window. If this has been addressed already, my apologies, but thought
 it
  worthwhile to mention.  
  
 
 I'm a total newbie when it comes to these issues, but it seems to me
 that Firefox behaves in the very same manner.  It's not limited to PHP
 sessions either.  It's always been my experience on any website that
 requires authentication, including the likes of Google Mail, etc.  When
 I want to run multiple sessions for different GMail accounts, for
 example, I just create a different user profile in Firefox. 
 
 It'd make sense for things to run this way, I think.  After all, I'd
 find it quite confusing if I log into Google Docs, open a document (by
 default, it opens in a new tab) and I had to log in yet again to be able
 to edit it.  
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
The point is you are misunderstanding how browsers work. What the server
app is seeing is a new login that replaces the first. This is the way
browsers work, and if it changed to the idea you have for it, then
millions of sites would suddenly fail to work; i.e. any site that
requires a new tab or window to be opened in order to function, like
banks, etc.

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




-- 
PHP General

RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Leon du Plessis
No problem! Thx

-Original Message-
From: Angelo Zanetti [mailto:ang...@zlogic.co.za] 
Sent: 20 August 2009 02:35 PM
To: 'Leon du Plessis'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

Hi Leon, 

No harm intended :) Just thought that people were missing my post now and
only answering yours.

Anyways hope your issue got resolved.

Angelo


-Original Message-
From: Leon du Plessis [mailto:l...@dsgnit.com] 
Sent: 20 August 2009 01:46 PM
To: php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

Hi Angelo, 

No need to be nasty and touchy. If you have done trouble to read I have
closed the discussion in a prior listing and referred back to your original
thread. thanks

-Original Message-
From: Angelo Zanetti [mailto:ang...@zlogic.co.za] 
Sent: 20 August 2009 01:21 PM
To: 'Leon du Plessis'; a...@ashleysheridan.co.uk
Cc: 'Nitebirdz'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

Hi Leon and all.

LEON you are misunderstanding how the sessions work. Also please start your
own thread and don't hijack mine.

To the rest that replied. Thanks, I am still stuck with the problem I have
asked the hosting company to check the storage capacity and also any other
issues with the SESSIONS on the server.

However if anyone has other things they think I can look at, I'd appreciate
that very much.

Thanks
Angelo
http://www.elemental.co.za


-Original Message-
From: Leon du Plessis [mailto:l...@dsgnit.com] 
Sent: 20 August 2009 12:04 PM
To: a...@ashleysheridan.co.uk
Cc: 'Nitebirdz'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

Thanks Ashley, 

I just want to iterate again that when a new page is opened by another
existing page in a new browser or Tab, the session_id is already created and
therefore the current way browsers work is in no way compremised. The new
browser/tab would receive the session id along with GET or POST variables.

What I am suggesting/hoping is that when a new browser is opened or a new
tab is opened via the application, the protocols would reckognize that this
is the first time the page is served and is not being called from another
page. That is, a new page is loaded by the user entering it, and NOT by
clicking login or some other link from an existing page.

Yes, I know..that creates other scenarios, so is happy to not meddle with
the way browsers work. It is just a limitation I will live with and can get
by with it.

Regards
Leon

-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: 20 August 2009 11:39 AM
To: Leon du Plessis
Cc: 'Nitebirdz'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

On Thu, 2009-08-20 at 10:50 +0200, Leon du Plessis wrote:
  It'd make sense for things to run this way, I think.  After all, I'd
 find it quite confusing if I log into Google Docs, open a document (by
 default, it opens in a new tab) and I had to log in yet again to be able
to
 edit it.
 
 Yes. I agree. But in this case the Tab being opened is used with the same
 authentication details either via POST, GET or Cookie variables. The
problem
 comes in when a totally different set of login credentials are being used
 (for the same tab/window).  Other user's login particulars should not
affect
 your login variables.
 
 -Original Message-
 From: Nitebirdz [mailto:nitebi...@sacredchaos.com] 
 Sent: 20 August 2009 10:40 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] SESSIONS lost sometimes
 
 On Thu, Aug 20, 2009 at 09:44:02AM +0200, Leon du Plessis wrote:
  
  Since we are on the subject: I have the following similar problem:
  
  When testing page on internet explorer, I find that one tab's variables
 can
  affect another tab's variables. Thus when having the same web-site open
 and
  using SESSION variables but for different users, Internet explorer can
  become disorientated. This also sometimes happen when I have two
  separate browsing windows open with Internet Explorer for the same site.
  
  I have yet to determine if this is an internet explorer, or PHP or
  combination of the two that is causing this condition. 
  
  To my understanding _SESSION variables should be maintained per session,
 tab
  or window. If this has been addressed already, my apologies, but thought
 it
  worthwhile to mention.  
  
 
 I'm a total newbie when it comes to these issues, but it seems to me
 that Firefox behaves in the very same manner.  It's not limited to PHP
 sessions either.  It's always been my experience on any website that
 requires authentication, including the likes of Google Mail, etc.  When
 I want to run multiple sessions for different GMail accounts, for
 example, I just create a different user profile in Firefox. 
 
 It'd make sense for things to run this way, I think.  After all, I'd
 find it quite confusing if I log into Google Docs, open a document (by
 default, it opens in a new tab) and I had to log in yet again

[PHP] SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS

2009-08-20 Thread Leon du Plessis
It is just strange that I have this condition now...maybe I missed it a
year ago ? 

 Having a different session start up for each window for tab would be a
major pain.

Why? 

People must please try and understand what I mean by NEW. It does not apply
to windows/tabs being opened from a link or request.

Imho, keeping the session per domain sounds wrong, it does not mean it is.
It would have been nice if:

Browser/tab one - my login detail container A.
Browser/tab two - my admin login container B.
(tabs/windows opened from browser one, then inherits container A naturally)
(Closing browser one, then destroys container A then naturally only)

NOT

Domain.com - one session container only.

Heck, I am surprised it works that way at all cause it sounds like the
domain can then only handle one user a time if arrays are not used or
profiles not created on FF no matter where the request come from, but, then
I am obviously missing something in this respect as stated. When I have time
I will reconstruct this concept again.

Thanks anyway guys. I received some helpful advise for future reference.

But please..I do not, like many others, want to start a war. I am ok with
things how they are. We can put this thing to rest.

-Original Message-
From: Floyd Resler [mailto:fres...@adex-intl.com] 
Sent: 20 August 2009 02:25 PM
To: Leon du Plessis
Cc: a...@dotcontent.net; php-general@lists.php.net
Subject: Re: [PHP] SESSIONS lost sometimes

Leon,
Sessions are used on a per-domain basis.  So, no matter how many  
windows or tabs you have open for mydomain.com it will be the same  
session for all.  Having a different session start up for each window  
or tab would be a major pain.  If you needed to keep track of a user  
ID, for example, you wouldn't be able to.  As already mentioned you  
can use different browsers.  You can also set up sub-domains which  
would each have their own sessions.

Take care,
Floyd

On Aug 20, 2009, at 4:26 AM, Leon du Plessis wrote:

  It's not an issue, it's a feature.

 Thanks Arno...but it is a pain also.
 If I work with user A in Tab1 (window1), I want to work with user B
 separately in Tab2. When user in Tab2 logs off, I still want user A  
 to work,
 and not suddenly have to re-login. Same with bank. If I work with my  
 company
 account, then my personal account must not become an issue because I  
 am on
 the same machine and site.

 I have no issue with using FF and IE to do testing as that takes  
 care of
 browser compatibility testing at the same time :-), but I think when  
 you
 start a new session with new values, it should be kept under that  
 window/tab
 alone. Cookies can take care of more details, but my opinion is data  
 should
 never be affected across windows/tabs unless the same user is logged  
 in on
 botheven then I would expect PHP to keep data per session. Maybe  
 it goes
 beyond being an IE or FF issue..the questiojn is...will PHP allow  
 variables
 from session A become corrupted when session B is in progress when  
 they
 should actually be handled seperately?

 In the end I think it is something I do wrong in PHP with the SESSION
 variables and how I clear themif so...I don't think PHP should  
 allow
 clearing SESSION variables from other sessions.

 -Original Message-
 From: Arno Kuhl [mailto:ak...@telkomsa.net]
 Sent: 20 August 2009 10:03 AM
 To: 'Leon du Plessis'; php-general@lists.php.net
 Subject: RE: [PHP] SESSIONS lost sometimes

 -Original Message-
 From: Leon du Plessis [mailto:l...@dsgnit.com]
 Sent: 20 August 2009 09:44 AM
 To: php-general@lists.php.net
 Subject: RE: [PHP] SESSIONS lost sometimes

 Since we are on the subject: I have the following similar problem:

 When testing page on internet explorer, I find that one tab's  
 variables can
 affect another tab's variables. Thus when having the same web-site  
 open and
 using SESSION variables but for different users, Internet explorer can
 become disorientated. This also sometimes happen when I have two
 separate browsing windows open with Internet Explorer for the same  
 site.

 I have yet to determine if this is an internet explorer, or PHP or
 combination of the two that is causing this condition.

 To my understanding _SESSION variables should be maintained per  
 session, tab
 or window. If this has been addressed already, my apologies, but  
 thought it
 worthwhile to mention.

 If someone perhaps have a solution or can confirm this as a known  
 issue and
 maybe is the same or related to Angelo's problem?

 

 If different browser windows/tabs on the same client-side computer  
 didn't
 share session info then you'd get the effect of being able to log  
 onto a
 site with one browser window, but find in a second browser window  
 that you
 were not yet logged on. Experience will tell you that you're logged  
 on in
 both browser windows (try it with your online bank). It's not an  
 issue, it's
 a feature. If you want

RE: [PHP] what to use instead of foreach

2009-04-14 Thread Leon du Plessis
Hi PJ,

Maybe you should post your code, or portion thereof. The trained eyes on the
list will quickly gather where the problem in the logic lies. 

Maybe you can also sacrifice some of your data or data structures if not too
sensitive. This will help to validate the route you are trying to follow.

Best wishes
Leon

-Original Message-
From: Jan G.B. [mailto:ro0ot.w...@googlemail.com] 
Sent: 14 April 2009 05:45 PM
To: PJ
Cc: Leon du Plessis; php-general@lists.php.net
Subject: Re: [PHP] what to use instead of foreach

2009/4/13 PJ af.gour...@videotron.ca:
 I have already tried with several count and for schemes. None work
 because foreach ignores any counters once in the loop. Also, this
 foreach is nested within another foreach; don't know if that affects
 anything.


Have you heard of while()? You can use it in combination with
array_pop() and count()

like:
?
while (($data = array_pop($array)) !== NULL) {
/* having $data and count($array) changes with every loop */
}
?

Bye

-- 
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



RE: [PHP] what to use instead of foreach

2009-04-13 Thread Leon du Plessis
Hi PJ, 

Ok, If I understand correctly you can attempt to alter your code as per
following example (I am breaking it down a little for readability):

a) If you only wish to output the authors, see also Mark Kelly's example,
You can simply output as many authors you have associated (you will need an
associated array!!:

Or b) I include the following alternative example:


$string_out = :
Foreach ($my_titles as $titles)
{
   Echo Title: $titles By:br;
   Foreach($my_authors[$title] as $author)
  $string_out .= $author, ; /* Building string */

   // Add br
   $string_out .= br;

   // Here you would replace your last comma with the  you want
   // There are a few ways to do this (like Mark Kelly's), but will try 
   // another way (older, maybe less complicated?).
   $final_string = substr($string_out,0,strrpos($string_out,,) - 1);
   $final_string .=. 
  substr($string_out,strrpos($string_out,,) + 1);
}


So all you need is to modal your data around this, and you should be fine. 
You could construct your arrays then as follows as an example:


$my_titles = array(title1,title2);
$my_authors[title1] = array(a someone,a notherone);
$my_authors[title2] = array(mr. a,mr. b);
... 

and so forth...how you construct the data is then very important as you can
then later use it simplify your coding as you progress and as demonstrated
below:

In future, where the need justifies it, you can construct your array to
already contain the needed string you want to output, it may help, but you
will sometimes have the same effort in constructing the data for the arrays,
so it is up to you to decide which approach is going to be best: e.g.
$my_titles = array(title1,title2);
$my_authors[title1] = array(a someone, a notherone  Mr. X);

Then you can simply echo the array value:
echo $my_authors[title1] . br;

Hope it is enough info for to work on for now!!

Have fun!
Leon

-Original Message-
From: PJ [mailto:af.gour...@videotron.ca] 
Sent: 13 April 2009 04:33 PM
To: Leon du Plessis
Cc: php-general@lists.php.net
Subject: Re: [PHP] what to use instead of foreach

Hi Leon,
Thanks for the suggestion; I'm quite new to all this, so it's a bit
complicated for my peanut brain.
I have already tried with several count and for schemes. None work
because foreach ignores any counters once in the loop. Also, this
foreach is nested within another foreach; don't know if that affects
anything.
I'll try to understand the second suggestion using for. I'll see what
comes up.
There are actually several conditions that have to be met:
1. if only 1 author = echo authorbr
2. if 2 authors = echo author  author1br
3. if more than 2 authors = echo author, author1, author2  author3br
That's what makes it a toughie

Leon du Plessis wrote:
 You may try something basic like:

 $b = 1;
 foreach ($my_array as $a)
 {
 echo  $a ;

 //Send new line to browser
 if ($b++ == 3) { echo br; $b = 1; }
 }

 Or there are some different ways to approach this also like:
 for ($a = current($my_array); $a; $a = next($my_array))
 {
 //Format 1
 echo  $a ;
 $a = next($my_array);

 //Format 2
 /* you may add checks here to see if $a contains data */
 echo  ~ $a ~ ; $a = next($my_array);

 //Format 3 + NEW LINE
 /* you may add checks here to see if $a contains data */
 echo  ~~ $a ~~br ;
 }

 This way you have some added control over the iteration through the array,
 and you can play around with when  how to display what.

 Regards.

 -Original Message-
 From: PJ [mailto:af.gour...@videotron.ca]
 Sent: 12 April 2009 08:57 PM
 To: php-general@lists.php.net
 Subject: [PHP] what to use instead of foreach

 foreach does not allow for different formatting for output...
 What could be used as a workaround?
 example:
 echo $some_result, br; // will print all results in 1 column
 echo $some_result, ,; // will print all results comma-separated in 1 row

 But how do you get result1, result2  result3 // with br at end ?

-- 
unheralded genius: A clean desk is the sign of a dull mind. 
-
Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com/andypantry.php

-- 
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



RE: [PHP] what to use instead of foreach

2009-04-13 Thread Leon du Plessis
Hi PJ, 

You may want to remove the , before the br...That was a slight oversight
on my partsorry.'bout that...I will leave you to do the fixing, but I am
sure you get the general idea.

Best wishes..Leon

-Original Message-
From: Leon du Plessis [mailto:l...@dsgnit.com] 
Sent: 13 April 2009 06:48 PM
To: 'PJ'
Cc: php-general@lists.php.net
Subject: RE: [PHP] what to use instead of foreach

Hi PJ, 

Ok, If I understand correctly you can attempt to alter your code as per
following example (I am breaking it down a little for readability):

a) If you only wish to output the authors, see also Mark Kelly's example,
You can simply output as many authors you have associated (you will need an
associated array!!:

Or b) I include the following alternative example:


$string_out = :
Foreach ($my_titles as $titles)
{
   Echo Title: $titles By:br;
   Foreach($my_authors[$title] as $author)
  $string_out .= $author, ; /* Building string */

   // Add br
   $string_out .= br;

   // Here you would replace your last comma with the  you want
   // There are a few ways to do this (like Mark Kelly's), but will try 
   // another way (older, maybe less complicated?).
   $final_string = substr($string_out,0,strrpos($string_out,,) - 1);
   $final_string .=. 
  substr($string_out,strrpos($string_out,,) + 1);
}


So all you need is to modal your data around this, and you should be fine. 
You could construct your arrays then as follows as an example:


$my_titles = array(title1,title2);
$my_authors[title1] = array(a someone,a notherone);
$my_authors[title2] = array(mr. a,mr. b);
... 

and so forth...how you construct the data is then very important as you can
then later use it simplify your coding as you progress and as demonstrated
below:

In future, where the need justifies it, you can construct your array to
already contain the needed string you want to output, it may help, but you
will sometimes have the same effort in constructing the data for the arrays,
so it is up to you to decide which approach is going to be best: e.g.
$my_titles = array(title1,title2);
$my_authors[title1] = array(a someone, a notherone  Mr. X);

Then you can simply echo the array value:
echo $my_authors[title1] . br;

Hope it is enough info for to work on for now!!

Have fun!
Leon

-Original Message-
From: PJ [mailto:af.gour...@videotron.ca] 
Sent: 13 April 2009 04:33 PM
To: Leon du Plessis
Cc: php-general@lists.php.net
Subject: Re: [PHP] what to use instead of foreach

Hi Leon,
Thanks for the suggestion; I'm quite new to all this, so it's a bit
complicated for my peanut brain.
I have already tried with several count and for schemes. None work
because foreach ignores any counters once in the loop. Also, this
foreach is nested within another foreach; don't know if that affects
anything.
I'll try to understand the second suggestion using for. I'll see what
comes up.
There are actually several conditions that have to be met:
1. if only 1 author = echo authorbr
2. if 2 authors = echo author  author1br
3. if more than 2 authors = echo author, author1, author2  author3br
That's what makes it a toughie

Leon du Plessis wrote:
 You may try something basic like:

 $b = 1;
 foreach ($my_array as $a)
 {
 echo  $a ;

 //Send new line to browser
 if ($b++ == 3) { echo br; $b = 1; }
 }

 Or there are some different ways to approach this also like:
 for ($a = current($my_array); $a; $a = next($my_array))
 {
 //Format 1
 echo  $a ;
 $a = next($my_array);

 //Format 2
 /* you may add checks here to see if $a contains data */
 echo  ~ $a ~ ; $a = next($my_array);

 //Format 3 + NEW LINE
 /* you may add checks here to see if $a contains data */
 echo  ~~ $a ~~br ;
 }

 This way you have some added control over the iteration through the array,
 and you can play around with when  how to display what.

 Regards.

 -Original Message-
 From: PJ [mailto:af.gour...@videotron.ca]
 Sent: 12 April 2009 08:57 PM
 To: php-general@lists.php.net
 Subject: [PHP] what to use instead of foreach

 foreach does not allow for different formatting for output...
 What could be used as a workaround?
 example:
 echo $some_result, br; // will print all results in 1 column
 echo $some_result, ,; // will print all results comma-separated in 1 row

 But how do you get result1, result2  result3 // with br at end ?

-- 
unheralded genius: A clean desk is the sign of a dull mind. 
-
Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com/andypantry.php

-- 
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


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



RE: [PHP] what to use instead of foreach

2009-04-12 Thread Leon du Plessis
You may try something basic like:

$b = 1;
foreach ($my_array as $a)
{  
echo  $a ;

//Send new line to browser
if ($b++ == 3) { echo br; $b = 1; }
}

Or there are some different ways to approach this also like:
for ($a = current($my_array); $a; $a = next($my_array))
{  
//Format 1
echo  $a ; 
$a = next($my_array);

//Format 2
/* you may add checks here to see if $a contains data */
echo   ~ $a ~ ; $a = next($my_array);

//Format 3 + NEW LINE
/* you may add checks here to see if $a contains data */
echo   ~~ $a ~~br ;
}

This way you have some added control over the iteration through the array,
and you can play around with when  how to display what.

Regards.

-Original Message-
From: PJ [mailto:af.gour...@videotron.ca] 
Sent: 12 April 2009 08:57 PM
To: php-general@lists.php.net
Subject: [PHP] what to use instead of foreach

foreach does not allow for different formatting for output...
What could be used as a workaround?
example:
echo $some_result, br; // will print all results in 1 column
echo $some_result, ,; // will print all results comma-separated in 1 row

But how do you get result1, result2  result3 // with br at end ?

-- 
unheralded genius: A clean desk is the sign of a dull mind. 
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
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



RE: [PHP] Button id's - firefox and IE different ?

2009-04-02 Thread Leon du Plessis

Another suggestion would be to use the Input tag as suggested by Richard, 

but rename the name value ie:

input type=submit name=btid1 value=Delete /
input type=submit name=btid2 value=Delete /
input type=submit name=btid3 value=Delete /

You can then use your PHP variable $_POST[btid1], $_POST[btid2] or
$_POST[btid3], etc, to determine relevant actions.


-Original Message-
From: Angus Mann [mailto:angusm...@pobox.com] 
Sent: 02 April 2009 12:45 PM
To: Richard Heyes
Cc: php-general@lists.php.net
Subject: Re: [PHP] Button id's - firefox and IE different ?

I can do as you suggest below, but then the buttons are labelled Delete 
Cancel and Save to the user.

The essential point is that they all need to say Delete. I know I can 
accomplish this by making multiple forms, each with its own button but for 
my purpose that's a pain is the ***.

IE returns the text displayed in the button regardless of the btid value. 
It seems to just ignore it.

Firefox returns the value assigned to btid as I intended regardless of the

text in the button that the user sees.



- Original Message - 
From: Richard Heyes rich...@php.net
To: Angus Mann angusm...@pobox.com
Cc: php-general@lists.php.net
Sent: Thursday, April 02, 2009 8:17 PM
Subject: Re: [PHP] Button id's - firefox and IE different ?


 Any suggestions ?

 Try this:

 input type=submit name=btid value=Delete /
 input type=submit name=btid value=Cancel /
 input type=submit name=btid value=Save /


 And then you can check the value of $_POST['btid']. Oh and btw...
 center... seriously?
 That's so 9 years ago. ;-)

 -- 
 Richard Heyes

 HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
 http://www.rgraph.net (Updated March 28th)

 -- 
 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


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



RE: [PHP] print a to z

2009-01-15 Thread Leon du Plessis
I used that notation before, and it did not work 100%. 
Adapt as follows:

for ($i = 'a'; $i = 'z'; $i++)
if ($i == aa) break; else echo $i;

-Original Message-
From: Paul M Foster [mailto:pa...@quillandmouse.com] 
Sent: 16 January 2009 07:55 AM
To: php-general@lists.php.net
Subject: Re: [PHP] print a to z

On Thu, Jan 15, 2009 at 08:32:14PM -0800, paragasu wrote:

 i have this cute little problem. i want to print a to z for site
navigation
 my first attempt work fine
 
 for($i = '65'; $i  '91'; ++$i)
   echo chr($i);
 
 but someone point me a more interesting solutions
 
 for($i = 'a'; $i  'z'; ++$i)
   echo $i
 
 the only problem with the 2nd solutions is it only print up to Y without
z.
 so how to print up to z with the 2nd solutions? because it turn out
 that you cant to something
 like for($i = 'a'; $i = 'z'; ++$i)..

for ($i = 'a'; $i = 'z'; $i++)
echo $i;

Paul

-- 
Paul M. Foster

-- 
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



RE: [PHP] Little regex help please...

2008-10-13 Thread Leon du Plessis

-Original Message-
From: Ryan S [mailto:[EMAIL PROTECTED] 
Sent: 13 October 2008 07:09 PM
To: Eric Butera; Boyd, Todd M.
Cc: php php
Subject: Re: [PHP] Little regex help please...

Hey Todd, Eric,

Thanks for replying.

 I don't believe you need both the / and the # for delimiters in your
 RegEx. Try using just # (since / is actually going to be in the text
 you're searching for) like this:

 ?php
  $data =
 file_get_contents(http://www.youtube.com/watch?v=oQ2dKXGAjNg;);
  preg_match('#title([^]*)/title#iU', $data, $match);
  $title = $match[1];
  echo $title;
 ?



 You can also escape the / like \/.


Ok, I changed it to:
?php
$data = file_get_contents(http://www.youtube.com/watch?v=oQ2dKXGAjNg;);
preg_match('/#title([^]*)\/title#iU',$data,$match);
$title=$match[1]; 
echo $title;
?
And this is the error i am getting:

Warning:  preg_match() [function.preg-match]: No ending delimiter '/' found
in C:\wamp\www\ezee\tests\get_remote_title.php on line 3


 Sorry forgot to include the list in my post to you

Here is another solution if you don't want to play around too much with
regex:

?php
$data = file_get_contents(http://www.youtube.com/watch?v=oQ2dKXGAjNg;);

$strt = strpos($data,title)+7;
$end = strpos($data,/title);
$len = $end - $strt;

$title= substr($data,$strt,$len);

echo $title
?

Produces:
YouTube - REALLY funny ad

As mentioned, you can probably neaten this up a bitregex may be too
complex for the simple requirement needed ?

But for fun, it will be nice to see get if preg_match can do it at some
stage :-)

Regards,

-- 
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



RE: [PHP] Adding encryption to passwords

2008-09-19 Thread Leon du Plessis

You can try the MySQL built in functions. Ie encode(str, key)

insert into test (password) values (encode(mypass,some key));

You can then use the decode() functions in your matching queries. 
You also need to consider security of your php code, as the key to decode
will be in the query strings. 

There are other built-in encryptions functions in MySQL you can explore.

-Original Message-
From: Thodoris [mailto:[EMAIL PROTECTED] 
Sent: 19 September 2008 10:25 AM
To: PHP General list
Subject: [PHP] Adding encryption to passwords

Hi guys I have developed an intranet web interface with user access. 
I am storing the passwords into a mysql table as raw text (I know not so 
secure). So I am adding group access features and I am thinking to 
encrypt the passwords because this seems to grow as a project although 
it started as a simple web tool.

So  what do you think is  the best way to use crypt, mcrypt, hash or 
perhaps md5 and what are really the differences because I am not sure if 
I get it right.

-- 
Thodoris


-- 
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



[PHP] hash_hmac: Encoding with two different results problem

2008-07-24 Thread Leon du Plessis
hi,
I hope this is the right group for this type of problem:

I am using hash_hmac to provide me with a sha1 encoded hash string. The 
problem is as follows:

$hash = hash_hmac('sha1', 
'030B6A05696E657400C54601C60001550187360603773500018707060373796E63000187340603687474703A2F2F772E73796E632E636F6D2F73796E630001C65901873A06032E2F636F6E7461637473000187070603436F6E74616374732044420001872E0603746578742F782D7663617264000101C6570187310603757365726E616D6500018732060370617373776F72640001010101',
 
'1234');

Note: it is important the key to use during encoding id 1234 for this 
example.

Result:
eb38ffd597c6d1e01cd24a0e46dff426354510fe

Using a hash calculator from slavasoft also yields this result, which 
indicate the encoding is fine.
eb38ffd597c6d1e01cd24a0e46dff426354510fe

However, Slavasoft's calculator has an option to provide the string as Text 
or Hex.

Selecting hex yields this result:
9f9be99ea5bf5ba009af0a5c12021f420cb27652  and this is the string I 
need!!!

So either hash_hmac function needs a way to let it know the string is of 
type hexor the string itself needs to be converted. I have tried some 
conversions on the string but to no avail.
Anyone have any thoughts?



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



[PHP] SOAP and php

2005-09-12 Thread Leon Vismer
Hi 

What would be the best option for PHP and SOAP support.

Many thanks
--
Leon

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



[PHP] Regular expression question

2005-08-11 Thread Leon Vismer
Hi 

I would like to convert from one naming convention within a sql statement to 
another.

I have the following,

code
$str = insert into userComment (userID, userName, userSurname) values (0, 
'Leon', 'Vismer');

$match = array(
/([a-z]+)(ID)/,
/([a-z]+)([A-Z])/
);

$replace = array(
\$1_id,
\$1_\$2
);

$nstr = preg_replace($match, $replace, $str);
echo $nstr .\n;
/code

the above gets me to 
insert into user_Comment (user_id, user_Name, user_Surname) values (0, 'Leon', 
'Vismer')

however I want to get to

insert into user_comment (user_id, user_name, user_surname) values (0, 'Leon', 
'Vismer')

Some help from the regex experts ;-)

Many thanks
--
Leon

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



Re: [PHP] Regular expression question

2005-08-11 Thread Leon Vismer
Hi

 Just a quick note; why dont' you search on user since it's the constant
 and replace 'user[A-Z]' with 'user_[a-z]' or in the case of userID
 'user[A-Z]{2}'

This is part of my problem user will not always be constant, I basically want 
to be able to change between two naming conventions.

Example:

userID becomes user_id
clientID becomes client_id
tableName becomes table_name
anotherTableName becomes another_table_name
etc.

Thanks
--
Leon

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



Re: [PHP] Regular expression question

2005-08-11 Thread Leon Vismer
Hi Robin

Many thanks for this,

how would one extend this to support the following:
$str = insert into userComment (userID, userName, userSurname) values (0, 
'Leon', 'mcDonald');

one does not want

$str = insert into user_comment (user_id, user_name, user_surname) values (0, 
'Leon', 'mc_donald');

unfortunately lookbehind assertions does not support non-fixed length chars so
/(?=(?!')[a-z])([A-Z]+)/e will work for 'mDonald' but the following will not 
work.

/(?=(?!')([a-z]+))([A-Z]+)/e

Any ideas?

Many thanks
--
Leon

 ?php
 $str = insert into userComment (userID, userName, userSurname) values
 (0, 'Leon', 'Vismer');

 $match  = '/(?=[a-z])([A-Z]+)/e';
 $replace = 'strtolower(_$1)';
 print preg_replace($match, $replace, $str);
 ?

 insert into user_comment (user_id, user_name, user_surname) values (0,
 'Leon', 'Vismer')

  -robin

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



Re: [PHP] redirect based off server string

2005-08-10 Thread Leon Vismer
If you are using apache you can use the redirect module

VirtualHost 152.1.45.10
 Servername www.ces.ncsu.edu
 ServerAlias *
 Redirect permanent / http://www.nc4h.org/
 /VirtualHost

--
Leon

On Wednesday 10 August 2005 16:52, Robert Sossomon wrote:
 Anyone have a script or know of a way to check and see what the url is of a
 system and then sending it to another url if it is not right?

 I have this problem where if someone is using:
 http://www.ces.ncsu.edu/depts/fourh
 instead of:
 http://www.nc4h.org

 to get to my site it is breaking other pieces within it (though there is
 code in place which supposedly stops this from happening, I have found that
 this is not the case)

 what I plan on doing is invoking the script on the main page of each man
 sub-directory and the main page so that it should catch the majority of
 folks.

 Any suggestions/help would be greatly appreciated!

 Robert

 --
 Robert Sossomon, Business and Technology Application Technician
 4-H Youth Development Department
 512 BrickHaven Drive Suite 220L, Campus Box 7606
 N.C. State University
 Raleigh NC 27695-7606
 Phone: 919/515-8474
 Fax:   919/515-7812
 [EMAIL PROTECTED]

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



Re: [PHP] html_entity_decode () for hellip;, rsquo;, etc.

2005-08-10 Thread Leon Vismer
Hi Marco

To awnser you question I do not know why it is excluded from the default 
decode array. Maybe it could be that these are multibyte characters (any 
takers)?

You can get a list of the entities that are changed

$trans = get_html_translation_table(HTML_ENTITIES);
echopre;print_r($trans);echo/pre;

to add some extras as you have below, use something similar to

function htmldecode($string)
{
$trans = get_html_translation_table(HTML_ENTITIES);
$trans[chr(0xe2).chr(0x80).chr(0xa6)] = 'hellip;';
$trans = array_flip($trans);
return strtr($string, $trans);
}

$string = hellip;amp;;
echo htmldecode($string) .\n;

Note: obviously hex e2 80 a6 make up the hellip chars.

Hope this helps

Cheers

--
Leon

On Wednesday 10 August 2005 20:55, Marco wrote:
 I tried using html_entity_decode () but why won't these characters decode:

 rsquo;
 ndash;
 hellip;
 ldquo;
 rdquo;

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



Re: [PHP] ampersands in href's

2005-06-04 Thread Leon Poon
The simplest way to make sure everything work well regardless of what the 
values are:


?
$url = somepage.php?var1=.urlencode($var1).var2=.urlencode($var2);
echo a href=\.htmlspecialchars($url).\;
?

htmlspecialchars() changes characters '', '', ''', '', '' into the HTML 
equivilant. And yup, you should do this for all *ML pages as long as the 
thing being printed is not part of the mark-up syntax.




Jack Jackson wrote:

Rory Browne wrote:

On 6/4/05, Jack Jackson [EMAIL PROTECTED] wrote:


Hi, Rory

Rory Browne wrote:


I think you have the idea. The 's are used to seperate the various
variables. If you want to set $p to something like 'Tom  Jerry' then
personally I'd do something like:

?php

$p = Tom  Jerry;
$s = Cat  Mouse;
printf(a href='{$_SERVER['PHP_SELF']}?p=%ss=%s, urlencode($p),
urlencode($s));

?


That's nice. To get more specific (because my code varies a bit from
yours and I don't wanna mess up the ) and ' and  s:
$p and $c are actually row ID numbers so up to 3 digits. So for example 
if


$p=1
$c=32

I was wanting to see a URL of

http://foo.com?r=1c=32



In that case, you can simply echo them out, once you're sure that $r,
and $c are actually integers.


I forgot to mention that above I did $r = intval($_GET[r])

!



Thanks, everyone!


echo a href='http://foo.com?r=$rc=$c'whatever/a

if not(sure they're integers, you could always
printf(a href=\http://foo.com?r=%dc=%d\;whatever/a, $r, $c);

Alternatively you could $r = (int)$r;

or echo a href='http://foo.com?r=; . (int)$r . c= . (int)$c .
'whatever/a;

There's more than one way to do it...


so was this the way to go?


//Make a thumbnail table of contents to display in the left sidebar

while ($sidebar = mysql_fetch_assoc($sidebar_result)) {
   $sidebar_thumbnails[] = a class='img-link'
href='{$_SERVER['PHP_SELF']}?p=%pc={$sidebar['art_id']}, urlencode($p)'
title=\{$sidebar['art_title']}\img class='sidebar-img'
src='{$image_dir}{$sidebar['art_thumbnail']}' width='50' height='60'
border='0' alt=\{$sidebar['art_title']}\ //a;
  }

?

Thanks in advance!




On 6/4/05, Jack Jackson [EMAIL PROTECTED] wrote:



Hi,

If I want to make a link to a URL which includes some GETs can I just 
do:


a href='{$_SERVER['PHP_SELF']}?p={$p}c={$s}' ... etc etc

or must I escape the ampersand somehow?

TIA,
--Jack

--
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








--
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



Re: [PHP] Re: 1 web site, 3 servers, 3 countries - best practises?

2005-04-22 Thread Leon Poon
I think he wants mirror, sort of...

I will do this if I were you:
Select the server wif the most bandwidth. Call this the master.
The other 2 are slaves.
To sync files:
==
Enable network file system server on the 2 slaves. Export the htdocs 
directories.

Setup the master to mount the exports.
Setup file monitoring tools (maybe fam?) on the master to copy new files to 
the mounted slave directories when alteration of files in htdocs is 
detected.

DO NOT instead mount exports of the master's htdocs on the slaves otherwise 
the slaves will be very slow in serving out files.

Of course, you have to enable security - things like IP 
restriction/encryption on the NFS.

To sync database:
=
Use database slaving tools?
If you are using MySQL, see 
http://mysql.hjc.edu.sg/doc/mysql/en/replication-intro.html. All updates 
from ANY server must be done at the master though.

Or you can just host the SQL server at the master. All queries goes to the 
master.


Hope this helps!

-Leon

- Original Message - 
From: Drewcore [EMAIL PROTECTED]
To: php php-general@lists.php.net
Sent: Friday, April 22, 2005 11:45 AM
Subject: Re: [PHP] Re: 1 web site, 3 servers, 3 countries - best practises?


well, i guess it all depends...
are you talking about having one server in south america that acts as
your database server, one server in asia that's your web server, and
then another server in north america that servers some other task?
or are you talking about having a localized database, http, etc,
server for each location (read: continent/country)?
the first is easy... it'll all just mesh... the second is more difficult.
drew
--
dc .. drewcore.com
--
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


Re: [PHP] Forms on PHP

2005-01-11 Thread Leon Poon
Refer to the following line numbers:
01  ?php
02  // Start of PHP code - Extract values from form.
03  /* Other values read */
04  $n=$_POST['n'];
05 
06  // Pass the data from the form to lightcurve_csharp
07  $command=./lightcurve_csharp $a $i $e $lomega $bomega $lambda $n;
08  $result=`$command`;
09 
10  $form_submitted=$_POST['form_sumbitted'];
11  if (isset($form_submitted)) {
12 if ($form_submitted) {
13 echo 'The form has been submittedbr';
14 unset($form_submitted);
15 }
16  } else
17 echo 'The form has not been submittedbr';
When the user first load the page, no data was posted. So there was no 
$_POST['form_sumbitted'] available. Line 10 will cause $form_submitted to 
contain the NULL value (I think). $form_submitted will evaluate to FALSE at 
line 12. Thus it will not display any message.

By the way, by doing line 10, $form_submitted would have been set regardless 
whether there is $_POST['form_sumbitted'], and line 11 will evaluate to TRUE 
always. Thus you will never ever see the 'form not been submitted' message.

Anyway, when you posted for the first time, $_POST['form_sumbitted'] is 
available. The 'The form has been submittedbr' message will be printed. 
After that, when you press Reload button on the browser, the post data will 
once again be sent from the user. (This is the behaviour of reloading a 
posted page. In Internet Explorer there should be a message dialog box 
asking the user whether to resend form data in order to refresh.) Reposting 
the data during the reload means that there will be 
$_POST['form_sumbitted'], thus once again the 'form hass been submitted' 
message.

In order to prevent this from happening, you should do a header('Location: 
success-page.php') on a successful submit. This is so that at the redirected 
page, the user would not have resent data even if he press the Reload 
button.

Hope this helps

-Leon 

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


Re: [PHP] sorting mysql results

2005-01-10 Thread Leon Poon
Sort when querying from database:
SELECT name, type FROM some_table ORDER BY type ASC, name ASC
- Original Message - 
From: Sebastian [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Tuesday, January 11, 2005 5:38 AM
Subject: [PHP] sorting mysql results


I have a list of rows in the database and i would like to sort them in two
categories.
example,
echo $row['name'] . '-' . $row['type'];
// output:
row 1 - files
row 2 - files
row 3 - music
row 4 - files
I would like this output:
files
--
row 1 - files
row 2 - files
row 4 - files
music
---
row 3 - music
if the $row['type'] is music i want to output an hr and the results 
below
it but below the files results.. makes sense?
i thought i remember doing this once using a dummy var but cant remember
how. i guess i could always run a second query, but would like to avoid
that.

thanks for any help.
--
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


Re: [PHP] PHP form POST question

2005-01-09 Thread Leon Poon
When you access /foo, the server will redirect the client to /foo/ (because 
it is a directory). At the redirected page, the post data will not be sent 
again by the browser thus there are no _POST values.

Try using action=/foo/. That may work.

- Original Message - 
From: James (IFMS) [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Monday, January 10, 2005 10:04 AM
Subject: [PHP] PHP form POST question


I just narrowed something down about forms and POST and would like 
education. In the following scenarios, all work except #4. $_POST is null. 
Why is that?

Setup:
1) Running on localhost
2) /foo/index.php has the following:
   ? var_dump($_POST); var_dump($_GET); ?
3) /index.php contends vary per scenario (below)
Running RHEL 3, all updates (PHP 4.3.2).
SCENARIO 1:
/index.php contains the following:
form method=get action=/foo/index.php
input name=foobutton type=submit
/form
In this case in /foo/index.php $_GET has the right value, i.e.
array('foobutton' = '');
SCENARIO 2:
/index.php contains the following:
form method=get action=/foo
input name=foobutton type=submit
/form
In this case in /foo/index.php $_GET has the right value, i.e.
array('foobutton' = '');
SCENARIO 3:
/index.php contains the following:
form method=post action=/foo/index.php
input name=foobutton type=submit
/form
In this case in /foo/index.php $_POST has the right value, i.e.
array('foobutton' = '');
SCENARIO 4:
/index.php contains the following:
form method=post action=/foo
input name=foobutton type=submit
/form
In this case in /foo/index.php $_POST is NULL.
HUH? Why is $_POST empty? Is Apache doing something to kill the form's 
post information when it has to resolve /foo to /foo/index.php?

--
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


Re: [PHP] PHP Web Mail

2004-07-05 Thread Jose Leon
Hello,
 Does anyone know a good PHP-based (free if possible) web mail other than
 UebiMiau that they would recommend?
Why not Squirrel Mail?

http://www.squirrelmail.org

Regards.
--
qadram :: software development
http://www.qadram.com

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



Re: [PHP] PHP Web Mail

2004-07-05 Thread Jose Leon
Hello,
On Mon, 5 Jul 2004 12:33:38 +0100, I.A. Gray [EMAIL PROTECTED] wrote:
 Thanks- looked at Squirrel Mail.  Looks really good, however we use POP3- I
 don't think Squirrel Mail uses POP3 does it?
SquirrelMail is a web interface to an IMAP mail server, you can set up
fetch mail to retrieve your POP3 mail accounts and put the mail into
the Cyrus IMAP server, that way, you can handle all your mail from a
single point.

Regards.
-- 
qadram :: software development
http://www.qadram.com

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



[PHP] Passing array as subject to preg_replace has odd behaviour with limit

2004-04-05 Thread Leon Derczynski
Hi everybody,

I'm sure this has been mentioned hundreds of times before, but why is 
preg_replace apparently ignoreing my limit when I pass it an array of text 
to work on (with just one string each for pattern and replacement)? Is it 
only obeying per element of the subject? If so, is there a way to correct 
this unwanted behaviour, maybe through setting a constant or something?

Cheers!

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Close on exit

2003-12-21 Thread David Leon
How can I stop php.exe closing after it performs a task? I am using Windows
XP Pro.

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



[PHP] How do I fake a FORM submission with POST Mothed from PHP

2003-12-08 Thread leon
Hi , guys 

   How can I POST a submit to a webserver and get the response content in PHP script?

   And if it must use CURL how can i add this module?
i configure PHP without --with-curl ,:(



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



[PHP] Excel Table download it

2003-11-24 Thread leon
hi~

I want generate an excel table  download it as a file (not view in IE), what HTML 
mimetype should i use?

leon
[EMAIL PROTECTED]
2003-11-24

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



Re: [PHP] Input field array ends up as Array string

2003-01-21 Thread Leon Mergen

Rick Emery [EMAIL PROTECTED] wrote in message
024801c2c15b$1a770e70$0500a8c0@honeybee">news:024801c2c15b$1a770e70$0500a8c0@honeybee...
 show us code

Learn how to quote. :)



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




Re: [PHP] How know how many sessions are active?

2003-01-19 Thread Leon Mergen

To help even more, if you're on a dedicated, this shell command will provide
you the amount of sessions active:

ls -l /tmp/sess* | wc -l

HTH

Justin French [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
If you're on a dedicated server (no other sites on the server), you could
just count the session files in /tmp.

Otherwise, the general consensus seems to be that you need to decide how
long a user is active for (say a minute, or 3, or an hour?), and save (eg)
the SID and timestamp in a file or MySQL table.

In theory, you then count the number of sessions that were created or
reactivated (restamped) within your definition of active time (eg 3 mins).


This has been discussed waaay too many time on the list... do a search on
the archives for 'active users', perhaps also try a search with the word
ASP too :)


Justin


on 19/01/03 10:27 PM, Jeremías Grunge ([EMAIL PROTECTED]) wrote:

 Sorry I'm novice.

 There is a way to know how many sessions are active and to get variables
or
 the id of them?

 Thanks






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




[PHP] Re: Ever complained about lousy PHP programmers?

2003-01-16 Thread Leon Mergen

Peter Hutnick [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I'm soliciting comments on style, technique, etc.  Be brutal, but don't
 get your feelings hurt if I don't take your comments as gospel.
 References will help me take comments to heart.

Heck, I don't have anything better to do at the moment anyway. All I can say
in first, I will not judge your style - it's all up to you.

Now, first of all, why did you this:

?php echo(?xml version=\1.0\ encoding=\UTF-8\ ?); ?

and not just:

?xml version=1.0 encoding=UTF-8 ?

? Less parsing for PHP :P

But other than that, I couldn't find anything very wrong about it... only
that I personally prefer to call a print() statement for everything, and
don't use PHP as an embedded language but just as a normal programming
language... But that's just me :P

Hope this helps you a little bit...

Regards,

Leon Mergen
http://www.antrophia.com/




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




[PHP] Re: difference between shared and /usr/bin/mysql

2003-01-15 Thread Leon Mergen

Gamin [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 ./configure --with-mysql=shared
 ./configure --with-mysql=/usr/bin/mysql
 What are the advantages/disadvatages of using either.

Somebody correct me if I'm wrong, but from what I know is that when using
shared it is compiled as a shared object and only loaded when needed. This
decreases ram usage (which is good) , but increases load (which is bad) .

If you have a few spare kb's of ram, I wouldn't recommend using shared...



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




[PHP] Re: All Request to the same script

2003-01-15 Thread Leon Mergen

[EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]..
.
 Is it possible to send all incoming requests to the same script within
 PHP?
 In other words: How can I get http://mysite/script.php to point to the
 same script as http://mysite/anotherscript.php ? And is it possible to do
 send a request like
 http://mysite/someextrapathinfo to the same php script?
 The background behind it is to create a controler that handles all
 incoming requests and dispatches them to different worker scripts as
 nessecary.

If you're using unix, use ln... type man ln for a manual...



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




[PHP] Re: Text editors

2003-01-07 Thread Leon Mergen
www.editplus.com


Karl James [EMAIL PROTECTED] wrote in message
007f01c2b633$7b746c50$cc6c2f04@karle8hnwwmn0f">news:007f01c2b633$7b746c50$cc6c2f04@karle8hnwwmn0f...
Hello guys,
Right now im using dreamweaver mx

I was wondering if anyone knew of any good free text editors that has
line counts
And is good for php….

Thanks
karl

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.434 / Virus Database: 243 - Release Date: 12/25/2002





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




[PHP] Re: PHP vs. ASP

2003-01-04 Thread Leon Mergen

Anthony Rodriguez [EMAIL PROTECTED] schreef in bericht
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 How does PHP differs from ASP?

search google on php vs asp ...



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




[PHP] Re: ImageCreateFromPNG

2003-01-03 Thread Leon Mergen
You haven't compiled PHP with png support.

Roy Van Arem [EMAIL PROTECTED] schreef in bericht
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 ImageCreateFromPNG does not work ...
 I use php4.3 on win2000 and ImageCreateFromPNG give an error...
 undefined function... how is that possible... can someone help me



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




[PHP] Re: include/require vs performance

2003-01-03 Thread Leon Mergen

Radek Zajkowski [EMAIL PROTECTED] schreef in bericht
news:[EMAIL PROTECTED]...
 Is there, was there ever issue around including a lot files via
 include(). I am running things on a local server so it's hard to gauge.

I think that the only source that could cause any problems with too many
files included will be your operating system (since that thing has certain
limitations on a max number of locked files for example) . Other than that,
I don't think so. I myself include about 15 files on certain pages. But it
is easy to make a test or anything...

Just make a PHP script that generates like 1000 php scripts called
include.test.x.php , where x is is a number, then the contents of those
scripts should by ? include(include.test. . (x+1) . .php);? or
something like that...

Then you are for sure, and you immediately also know how much performance is
lost for including 1000 files :)



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




Re: [PHP] Re: include/require vs performance

2003-01-03 Thread Leon Mergen

Stephan Seidt [EMAIL PROTECTED] schreef in bericht
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I guess that PHP will close file 1 before it opens
 file 2 and so on.. For example :

 include 'foo';
 include 'bar';

 When bar is being opened foo is already closed.

Hmmm, i think the parser is built recursive, so at the moment it sees an
include 'foo'; , it will look in foo, parse that one, and after it has
finished foo, it will continue with the main script...



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




[PHP] Re: [PHP-DEV] PHP Look Back 2002

2002-12-30 Thread Leon Atkinson
A friend of mine had an uncle who taught dancing to middle-aged couples.
One day he visited some lessons and noticed that all the couples were
fussing, stepping on each other's feet and arguing.  When he asked, what
gives?  his uncle told him, if you're not fighting, you're not dancing.
(It may help to imagine this said with a yiddish accent).  Damn me if this
doesn't describe the PHP community.

Thanks for reminding us to keep our sense of humor, Derick. ;)

Leon



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




Re: [PHP] How To Get Last Item Of An Array?

2002-12-25 Thread Leon Mergen

John W. Holmes [EMAIL PROTECTED] schreef in bericht
000401c2ac54$142032c0$7c02a8c0@coconut">news:000401c2ac54$142032c0$7c02a8c0@coconut...
 Kind of begs the question of why can't you just select what you need
 with the proper query, instead of loading everything into an array...

Yeah, just add limit 0,1 desc to the query



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




[PHP] Creating my own External Module for PHP

2002-12-24 Thread Leon Mergen
Hello,

I have a little question to which I hope to find an anwser in here.
Currently, I have a big script which receives approx 1.5 million hits every
day. Since this script does some common calculations that underlying scripts
use, I want to rewrite this into C and initially make it an external module
for beta testing and then eventually compile it directly into PHP.

Now, I got this really good book, Web Application Development with PHP by
Ratschiller and Gerken. It has a complete chapter devoted to hacking the
core of PHP which shows how to create extensions.

Now, they describe 2 common ways of hacking the core... making a shared
object (which is what I want at this point) , or compiling the extension
right into the core. They decribe how to make your extension with
~/ext/ext_skel , but they don't describe which steps to take when you only
want to make a shared object... the only thing they say is at this point,
you should have a new PHP binary or a .so file ... but they never gave any
indication how to chose... they just asume you want a new php binary or sth.

Now, can anyone provide me with a few brief description (a few steps) how to
make your own dynamically loadable module in PHP?

Thanks in advance.

Regards,

Leon Mergen



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




Re: [PHP] Creating my own External Module for PHP

2002-12-24 Thread Leon Mergen
Hey! That worked!

Thanks Rasmus!

Grtz,

Leon Mergen

Rasmus Lerdorf [EMAIL PROTECTED] schreef in bericht
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Just run phpize in your directory and then do a ./configure  make
 If your config.m4 was correct you should now have a modules/foo.so in your
 dir.

 -Rasmus

 On Tue, 24 Dec 2002, Leon Mergen wrote:

  Hello,
 
  I have a little question to which I hope to find an anwser in here.
  Currently, I have a big script which receives approx 1.5 million hits
every
  day. Since this script does some common calculations that underlying
scripts
  use, I want to rewrite this into C and initially make it an external
module
  for beta testing and then eventually compile it directly into PHP.
 
  Now, I got this really good book, Web Application Development with PHP
by
  Ratschiller and Gerken. It has a complete chapter devoted to hacking
the
  core of PHP which shows how to create extensions.
 
  Now, they describe 2 common ways of hacking the core... making a shared
  object (which is what I want at this point) , or compiling the extension
  right into the core. They decribe how to make your extension with
  ~/ext/ext_skel , but they don't describe which steps to take when you
only
  want to make a shared object... the only thing they say is at this
point,
  you should have a new PHP binary or a .so file ... but they never gave
any
  indication how to chose... they just asume you want a new php binary or
sth.
 
  Now, can anyone provide me with a few brief description (a few steps)
how to
  make your own dynamically loadable module in PHP?
 
  Thanks in advance.
 
  Regards,
 
  Leon Mergen
 
 
 
  --
  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




[PHP] Re: $_SESSION[] and register_globals=on

2002-09-27 Thread Leon Mergen


Andre Dubuc [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 A short question:

 My IP informed me that they have register_globals=on in their php.ini. Is
 this going to cause problems with my scripts that were written  using
$_POST,
 $_SESSION, etc?

No, if everything is setup correctly both will work now. Otherwise, a lot of
websites would have many many problems with the transition phase between
register_globals = on and register_globals = off.

Grtz,

Leon



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




[PHP] Re: question about taking post to session

2002-09-21 Thread Leon Mergen


Randy Johnson [EMAIL PROTECTED] wrote in message
000901c2613d$e9223e30$c100a8c0@rjmarket">news:000901c2613d$e9223e30$c100a8c0@rjmarket...
 how could i take all the variables in $_POST[] and move them to
 $_SESSION[]?

If I understand correct, you will want something like this:

?
$var = $_POST[var];
session_start();
session_register(var);
?

And now, in all the scripts on your site, when you execute the
session_start() function, $_SESSION[var] contains the original contents of
$_POST[var] .

Grtz,

Leon



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




[PHP] Compiling PHP

2002-07-06 Thread Leon Mergen

Hello,

I'm currently camping with a problem... I have written a PHP application for
a client of mine, however, I do not want have him seeing the source code. I
know Zend has the Zend Encoder, however, this piece of software costs $2400
and since this is a one-time encoding request, I think this is a bit too
much ...

I want to know if anyone else knows another less expensive option to do
this.

Thanks in advance,

Leon  Mergen



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




[PHP] Strange url include problem

2002-07-01 Thread Leon Mergen

Hello,

I'm having a little bit problems with including an url into my page...

When I do this:

include (http://www.google.com/search?q=testie=UTF-8oe=UTF8hl=nllr=;);

PHP returns an error:

Warning: Failed opening
'http://www.google.com/search?q=testie=UTF-8oe=UTF8hl=nllr=' for
inclusion (include_path='.:/php/includes:/usr/share/php') in
/home/virtual/site6/fst/var/www/html/search/reply.php on line 64

This certainly makes me wonder, since that page loads perfectly in my
browser, and http://www.google.com/ works perfectly... anyone knows what I'm
doing wrong?

Thanks in advance,

Leon Mergen



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




[PHP] Re: php-speed

2002-06-13 Thread Leon Mergen


Philipp Melab [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 - embedding PHP in HTML
 - or printing HTML via PHP

With embedding PHP in HTML, do you mean using server side includes or do you
mean by having a .php file and having a layout like this:

html
head
title?=$title;?/title
body
?
code();
?
/body
/html

Regards,

Leon Mergen



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




[PHP] Re: php-speed

2002-06-13 Thread Leon Mergen


Philipp Melab [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Yes, Ithought that embedding must be faster too. But I was confused
because
 in nearly every PHP-Beginner Tutorial/Book I've seen the Hello-World
 Example looks like this:

 ?
 echo html;
 echo head;
 echo title.../title;
 echo /head;

 echo body;
 echo pHello World!/p;
 echo /body;
 echo /html;
 ?

Hello Philipp,

I think that must be because it's the most easy to explain... It's very easy
for people having experience with Perl, since Perl works that way...

I personally only use templates (I even wrote a caching template engine) ,
so that would be the last step in layout I think ;)

Regards,

Leon Mergen



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




Re: [PHP] Array into database

2002-06-12 Thread Leon Mergen


Stuart Dallas [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 As far as I know, serialize will handle multi-dimensional arrays. If I
were you
 I would suck it and see.

And how should I store a serialized variable in my database? As String or as
Blob?



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




[PHP] Array questions...

2002-06-12 Thread Leon Mergen

Hello,

Assume I have the following array:

$array = array (
 apple = cherry,
 foo = bar,
 wom = bat
);

How could I easy remove the key and the value of the key foo from that
array?

Also, what is the best (and quickest) way to add a key with a value to the
end of this array?

Thanks in advance,

Leon Mergen



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




[PHP] Re: sending 1000 emails to subscribed members via php?

2002-06-12 Thread Leon Mergen


Andy [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Anyway what do I do if I would have 1 members. This might take lots
of
  cpu?! So I would like to keep it via my webinterface, but be able to
email
  to all members.

Hello Andy,

My suggestion is to just make a HTML file, do an auto-refresh or sth to the
url with a variable ?start=$x , and make that refresh after 2 seconds...
your php script sends emails to 25 people per cycle, and you just walk away
from your computer and let it run for a few minutes...

I do that for my mailing list which is over 30,000 people large...

If you don't have the time to build something like that, there's always the
BCC option ;)

Hope this helps you.

Regards,

Leon Mergen



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




[PHP] unset($array[value]) does not work?

2002-06-12 Thread Leon Mergen

Hello,

I am currently testing out some things with removing elements from arrays,
and I find it strange that the following statement does not work for me:

unset($array['element'])

I wrote a little test script, you can see the source at
http://www.antrophia.com/test.txt and the executable at
http://www.antrophia.com/test.php ... Now, if you look at the last part:

unset ($unserialized['foo']);
if (key_exists(foo, $unserialized)) { echo foo exists!\n; }
if (key_exists(wom, $unserialized)) { echo wom exists!\n\n; }

You will see that $unserialized['foo'] still exists! Can anyone explain me
what I'm doing wrong?

Thanks in advance,

Leon Mergen



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




[PHP] Array into database

2002-06-11 Thread Leon Mergen

Hello,

I would like to know wether it's possible to put an array into a database?
If not, what is the best way to archieve something like that?

Thanks in advance,

Leon Mergen



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




Re: [PHP] Array into database

2002-06-11 Thread Leon Mergen

So this would handle 2-demensional arrays too?

So, if I have

$array = (
foo = bar,
wom = bat
);


it would work?

And darn, that I didn't come up with this (I'm familliar with Java, and they
use Serializable) ...

Stuart Dallas [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Tuesday, June 11, 2002 at 10:25:36 PM, you wrote:
  I would like to know wether it's possible to put an array into a
database?
  If not, what is the best way to archieve something like that?

 Yes it is. See http://www.php.net/serialize

 --
 Stuart




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




Re: [PHP] Re: Debugger

2002-05-11 Thread Jose Leon

Hello:
 He said php -l will let you know where your syntax errors are.
And what this has to do with my question? I was asking for a debugger, 
not for an error report. I want a mechanism to debug php programs step 
by step, watch variables and so on.

Regards.


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




Re: [PHP] Re: Debugger

2002-05-11 Thread Jose Leon

Hello:
 I think the OP has already looked at it, and wanted something 
 better :)

Yes, that's right, but I'm not saying dbg isn't good, I just said is 
too much complicated (AFAIK):
-Must have a listener running
-Use COM to interface with it
-User installation too hard:
 Change php.ini to load the extension
 Keep track of the php version and the extension version

I really like the Komodo solution, just copy a dll and it changes the 
php.ini for you. But I still must keep track of the PHP version.

It would be nice that php itself incoporates a system to debug php 
programs, like in PHP 3, in that way a development tool for php would 
be enabled to debug modifying the php.ini with debug.enabled=true and 
listening to a port. The system will work on any php distribution 
because will be part of php itself. Why the debugger was removed from 
PHP 3?

Regards.



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




[PHP] Debugger

2002-05-10 Thread Jose Leon

Hello:
  I have been browsing the web for a good solution to debug php code, I 
have found several ones, but none of them meet my requeriments. I 
create a development tool for PHP (QaDRAM Studio) and I want to be able 
to debug php code with it, my question here is: 

Why PHP 4 has no built-in debug features? This will simplify the setup 
for debugging php code and will allow php development tools provide 
debug support in a convenient way, instead force the user to change the 
php.ini file to support debug and to don't be able to debug every time 
the php version changes.

I have examined DBG and it's the one that fits my needs better, but 
there's not too much information on how to use it and what I have found 
is not complete. Also requires to load a 'listener' to be able to debug 
remotely. The Komodo solution looks nicer, but is propietary. Any help 
or comments?

Regards.



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




[PHP] Re: Debugger

2002-05-10 Thread Jose Leon

 php -l will let you know where your syntax errors are.

What?

Regards


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




[PHP] weird fopen problem

2002-01-10 Thread Zhang, Leon (STHK/Zh)

Hi Jon,
Can you tell me how you solve this at last,I met the same problem in my php
script.,I am really new to Linux and Apache.Where and how to set the
permission to ensure that all common users can write this file?

Regards
Leon


-原始邮件-
发件人: Jon Farmer [mailto:[EMAIL PROTECTED]]
发送时间: 10, January, 2002 17:08
收件人: PHP General Mailing List
主题: [PHP] weird fopen problem


I am getting a  the follwing error:

Warning: fopen(/home/jon/pgpfiles/sgsdgsdg,w) - Permission denied in
/home/ethiorg/public_html/test.php on line 2

Warning: Supplied argument is not a valid File-Handle resource in
/home/ethiorg/public_html/test.php on line 3

Warning: Supplied argument is not a valid File-Handle resource in
/home/ethiorg/public_html/test.php on line 4

from the following script:

?
$file = fopen(/home/jon/pgpfiles/sgsdgsdg,w);
fputs($file, this is a test\n);
fclose($file);
?

the directory /home/jon/pgpfiles has mode 777 and is owned by nobody and
group is nobody. Apache runs under user nobody.

Any ideas?



--
Jon Farmer
Systems Programmer, Entanet www.enta.net
Tel 01952 428969 Mob 07763 620378
PGP Key available, send email with subject: Send PGP Key



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




re: [PHP] How to add a carriage return in the end when using implode?

2002-01-08 Thread Zhang, Leon (STHK/Zh)

Yes,I have just worked out ,thank you Jason.


-原始邮件-
发件人: Jason Wong [mailto:[EMAIL PROTECTED]]
发送时间: 08 January, 2002 16:46
收件人: [EMAIL PROTECTED]
主题: Re: [PHP] How to add a carriage return in the end when using implode?


On Tuesday 08 January 2002 14:18, Zhang, Leon (STHK/Zh) wrote:
 $subdata has been changed before

 then $data[$index]=implode(,, $subdata); --what should I
 change here ?

 rewrite the file like this :

 $data[$index]=$data[$index];
 $fp=fopen($datafile,w+);
 $a=0;
 do{
 fputs($fp,$data[$a]);--or here?.
 $a++;
 }while($acount($data));
 fclose($fp);

 however if one line of the $datab has been implode with $subdata ,there
 will not be a 'return' in the final text file ,
 this line just is joined with the next line ,what should I do here to add
 the $data as a single line?

Not sure if I understand you correctly. If you just want to add a newline 
character then you can try this:

  $data[$index]=implode(,, $subdata) . \n;

hth
-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
BASIC is the Computer Science equivalent of `Scientific Creationism'.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] IP address from which country

2002-01-08 Thread Zhang, Leon (STHK/Zh)



Hi,
In php ,we can easily get 
the ip address of a connected computer ,but I always see on the web that there are some pages can 
tell you where you are from,so there must be a complete table show the relation 
of the ip address and country or region ,where can I find this 
.

Thanks .
Leon


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


re: [PHP] IP address from which country

2002-01-08 Thread Zhang, Leon (STHK/Zh)


Thank you Andrew,but in China mainland ,I saw many websites can even tells
the province information which the user come from and I think in USA the
State information can also be gotten from the visitor's ip address.BTW,in
PHP what we can get is just the ip address of the user how can we get the
host name ?Anything missed here?
Regards
Leon


-ԭʼÓʼþ-
·¢¼þÈË: Andrew Brampton [mailto:[EMAIL PROTECTED]]
·¢ËÍʱ¼ä: 09 January, 2002 9:46
ÊÕ¼þÈË: Zhang, Leon (STHK/Zh)
³­ËÍ: [EMAIL PROTECTED]
Ö÷Ìâ: Re: [PHP] IP address from which country


No such table, the best you can do is look at their hostname and parse the
last part ie .co.uk or .com... And then u can try and figure where they are
from that

Andrew
  - Original Message - 
  From: Zhang, Leon (STHK/Zh) 
  To: [EMAIL PROTECTED] 
  Sent: Wednesday, January 09, 2002 1:03 AM
  Subject: [PHP] IP address from which country


  Hi,
   In php ,we can easily get the ip address of a connected computer ,but I
always see on the web that there are some pages can tell you where you are
from,so there must be a complete table show the relation of the ip address
and country or region ,where can I find this .

  Thanks .
  Leon




--


  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




re: [PHP] IP address from which country

2002-01-08 Thread Zhang, Leon (STHK/Zh)

Thank you Jason ,I will check the Digital Envoy to get more information
,have you got the website address of it?



-ԭʼÓʼþ-
·¢¼þÈË: Jason Murray [mailto:[EMAIL PROTECTED]]
·¢ËÍʱ¼ä: 09 January, 2002 10:06
ÊÕ¼þÈË: 'Zhang, Leon (STHK/Zh)'; [EMAIL PROTECTED]
³­ËÍ: [EMAIL PROTECTED]
Ö÷Ìâ: RE: [PHP] IP address from which country


 Thank you Andrew,but in China mainland ,I saw many websites can even tells
 the province information which the user come from and I think in USA the
 State information can also be gotten from the visitor's ip address.BTW,in
 PHP what we can get is just the ip address of the user how can we get the
 host name ?Anything missed here?

A database may exist for IPs in China (I don't know), but outside of China 
it's impossible to tell with much accuracy which country an IP is in. You
could look at Digital Envoy, which was an attempt a couple of years ago
to 'map the internet' and obtain exactly the data you're referring to. The
problem is that as soon as that data is published it's out of date due to
routing changes and network configuration changes.

You can do a reverse lookup on the IP address to get the hostname, but you
can rely on that even less - for example, a hostname ending in aol.com could

be in the USA, Europe, Asia, or Australia these days.

Jason

-- 
Jason Murray
[EMAIL PROTECTED]
Web Developer, Melbourne IT
Work now, freak later!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] php4 startup error

2002-01-07 Thread Zhang, Leon (STHK/Zh)



hi,
I 
have installed php-4.0.0-Win32(into 
c:\php) and apache_1_3_9_win32(into 
C:\Program Files\Apache Group\Apache\ ) on my window98,the apache alone can be 
run normally,however when I run a test.php,windows told me the general protection error on 
PHP4TS.DLL and let me see the error log ,this is what I found in 
it:

[Tue Jan 08 09:45:55 2002] [error] [client 127.0.0.1] 
Premature end of script headers: c:/php/php.exe


following are some 
configurtation in php.ini:
include_path= 
; UNIX: "/path1:/path2" Windows: "\path1;\path2"doc_root= 
C:\Program Files\Apache Group\Apache\htdocs; the 
root of the php pages, used only if 
nonemptyuser_dir=; the directory 
under which php opens the script using /~username, used only if 
nonempty;upload_tmp_dir= 
; temporary directory for HTTP uploaded files (will use system default if not 
specified)upload_max_filesize = 2097152 
; 2 Meg default limit on file 
uploadsextension_dir=c:\php; directory 
in which the loadable extensions (modules) reside

following are some configurtation 
in httpd.conf:
ScriptAlias /php "c:\php\php.exe" 
Action application/x-httpd-php "/php" AddType application/x-httpd-php 
.php .php3 


Can anyone give me a hand on 
this ?

Thank you in 
advance.

Leon 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


[PHP] How to add a carriage return in the end when using implode?

2002-01-07 Thread Zhang, Leon (STHK/Zh)



$subdata has been changed 
before

then 
$data[$index]=implode(",", $subdata);--what shouldI change 
here?

rewrite the file like this 
:

$data[$index]=$data[$index];$fp=fopen($datafile,"w+"); 
$a=0; 
do{ fputs($fp,$data[$a]);--or 
here?. 
$a++; 
}while($acount($data));fclose($fp);

however if one line of the 
$datab has been implode with $subdata ,there will not be a 'return' in the final 
text file ,
this line just is joined with 
the next line ,what should I do here to add the $data as a single 
line?


Thanks

Leon


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


[PHP] How to read/write form/into certain place in a text file

2002-01-06 Thread Zhang, Leon (STHK/Zh)



hi,
 A text file has 
been formatted ,how to read/write form/into certain place in a text 
file.
For example,read form letter 5 
to 10 in line 4 ,and after some procedure ,write into the same 
place.
 Another question is that 
if a user has opened the file to read and write ,what will happen if another one 
will open and write the same file?
 Thank you in 
advance.

Leon

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


re: [PHP] How to read/write form/into certain place in a text file

2002-01-06 Thread Zhang, Leon (STHK/Zh)



Does anybody know 
this?
Please give me 
some advice,any help will be appreciated.

  -ԭʼÓʼþ-·¢¼þÈË: Zhang, Leon (STHK/Zh) 
  [mailto:[EMAIL PROTECTED]]·¢ËÍʱ¼ä: 07 January, 2002 
  9:56ÊÕ¼þÈË: [EMAIL PROTECTED]Ö÷Ìâ: [PHP] How to 
  read/write form/into certain place in a text file
  hi,
   A text file has 
  been formatted ,how to read/write form/into certain place in a text 
  file.
  For example,read form letter 
  5 to 10 in line 4 ,and after some procedure ,write into the same 
  place.
   Another question is 
  that if a user has opened the file to read and write ,what will happen if 
  another one will open and write the same file?
   Thank you in 
  advance.
  
  Leon

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


re: [PHP] How to read/write form/into certain place in a text file

2002-01-06 Thread Zhang, Leon (STHK/Zh)

Thank you ,Jimmy .



-ԭʼÓʼþ-
·¢¼þÈË: Jimmy [mailto:[EMAIL PROTECTED]]
·¢ËÍʱ¼ä: 07 January, 2002 12:13
ÊÕ¼þÈË: [EMAIL PROTECTED]
Ö÷Ìâ: Re: [PHP] How to read/write form/into certain place in a text file


Hi Leon,

 For example,read form letter 5 to 10 in line 4 ,and after some procedure
 ,write into the same place.

if the file is not too big, you can use file() function which will
return an array containing the content of the file per line.
combine this with substr() to read from specific column.
to write use substr_replace().

if the file is big, then doing file() is not advised, you should read
the file as stream. read the following functions:
fopen(), fclose(), fseek(), fread(), fwrite().

   Another question is that if a user has opened the file to read and write
,
 what will happen if another one will open and write the same file?

php doesnt handle file locking automatically, so i think it would
depend on the OS. if you want to handle file locking, read about flock().

--
Jimmy

God is greater than your greatest problem


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Regular expression question

2001-11-09 Thread Leon Mergen

Hello,

I have a little question regarding regular expressions... I want to check
for the pattern

$num::

But, $num may not be started with another number (assume the number will be
51 , 1 will also match (the pattern 1:: is available in 51::) ... Currently,
my regular expression is:

eregi(([^0-9]$num::), $string);

But that doesn't seem to work... The other option, the start of a line or a
: also didn't work:

eregi(([^|:]$sess_id::), $string);

Anyone can help me with this?

Thanks in advance,

Leon Mergen


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] MySQL4

2001-10-26 Thread Leon Mergen

Hello,

Just curious, before I get into the heat, but did anyone who already has installed 
MySQL 4 had any problems compiling PHP?

Thanks in advance,

Leon Mergen



[PHP] Regex problem

2001-10-25 Thread Leon Mergen

Hi there,

I am camping with a little regular expressions problem...

Problem: I want to check if $variable begins with a * (star), and it doesn't matter if 
it starts with plenty of spaces...

My solution:
ereg(^[:space:]*\*,$variable)

But, it doesn't seem to work with the space part... The regex:

ereg(^\*,$variable)

does work, but that doesn't include spaces at the start... How can I extend this one 
so that it doesn't matter if there are a lot of spaces at the begin?

Thanks in advance,

Leon Mergen



[PHP] HTML in XML???

2001-07-18 Thread Leon

Hi,
Is there some way to include HTML tags in a XML doc???
I want to use a XML document to include HTML data for my
webpage. I have made a solution of replacing a special word to
the '' and ' of a HTML tag.
But I think my solution is very stupid.

And is there a special php xml newsgroup??

thanks,
Leon



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: mysql error

2001-07-15 Thread Leon

Maybe you run out of diskspace??

Greets, Leon

Elias wrote:

 Table is full?

 did you try searching MySql.com for Table is full error message?

 Andreas ) [EMAIL PROTECTED] wrote in message
 000c01c10b81$c765aa60$8d0a@devel01">news:000c01c10b81$c765aa60$8d0a@devel01...
 hi all,

 my script was now working for month but now
 suddenly get this error:

 The table 'SQL90cb_0' is full

 SELECT DISTINCT t1.id,t1.textd FROM tblEntry AS t1,tblTopic AS t2 ORDER BY
 t2.named,t1.textd
 anyone know whats the problem ?

 thank you

 andreas


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Site Searchable function

2001-04-20 Thread ~~~LeoN~

On 19 Apr 2001 13:25:09 -0700 impersonator of [EMAIL PROTECTED] ("Steve
Lawson") planted I saw in php.general:

fopen("http://localhost/name-of-file") will return the rendered page instead

Sounds good (theoretically:). Hovever, in practical attempt on my remote
server it gave:

 Warning:  fopen("http://my.domain/file_name.htm","r") - A socket must be
already connected. in ...etc on line 304 

where it worked ok with 'filesystem open' (On my home window localhost, it
worked though).  Suggestions, how to go around this problem?

Leon.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] No character set?

2001-04-06 Thread Leon Mergen

Hello all,

Today, I compiled my PHP as CGI, since I want to use some PHP scripts in cron jobs. 
Shouldn't be too hard, I tought, and compiled with

./configure --with-mysql

For some strange reason, it does not work. Look at this:

[root@blazebox cron]# php ./missiles.php
File 'NONEXISTENT/charsets/?.conf' not found (Errcode: 2)
Character set '#7' is not a compiled character set and is not specified in the 
'NONEXISTENT/charsets/Index' file
X-Powered-By: PHP/4.0.4pl1
Content-type: text/html

br
bWarning/b:  MySQL Connection Failed: Can't initialize character set 7 (path: 
default)
 in b./missiles.php/b on line b5/bbr
[root@blazebox cron]#

Anyone has any idea what is causing this problem, and if/how I can fix it?

Thanks in advance,

_
Leon Mergen
[EMAIL PROTECTED]
President of Operations
BlazeBox, Inc.
ICQ: 55677353



[PHP] Safe mode?

2001-03-02 Thread Leon Mergen

How can I turn off safe_mode using php.ini with php4.0.3pl1? All this doesn't work:

safe_mode="off"
safe_mode=off
safe_mode="0"
safe_mode=0
safe_mode="Off"
safe_mode=Off

Anyone has an idea?


Leon Mergen
[EMAIL PROTECTED]
President of Technical Operations
BlazeBox, Inc.
ICQ: 55677353