php-general Digest 25 Apr 2006 05:14:18 -0000 Issue 4091

Topics (messages 234624 through 234650):

list noise [WAS: How to find <img> tag and get src of image]
        234624 by: Paul Novitski
        234625 by: Jay Blanchard
        234626 by: John Nichel

Re: shopping carts
        234627 by: tedd
        234628 by: Ryan A
        234629 by: Jay Blanchard
        234632 by: Ryan A
        234633 by: Tom Cruickshank
        234637 by: Ryan A
        234639 by: Lisa A

Reusable Singleton pattern using PHP5
        234630 by: Simas Toleikis
        234631 by: Jochem Maas
        234634 by: Simas Toleikis
        234644 by: Jochem Maas

Session Array Disappears
        234635 by: Webmaster
        234636 by: Brady Mitchell
        234647 by: Webmaster
        234648 by: Al
        234649 by: Webmaster

how to keep spaces in parameters in URL?
        234638 by: Bing Du
        234640 by: Chrome
        234641 by: Jeremy Schreckhise

Booleans in lowercase or uppercase
        234642 by: Jesper Forsberg
        234643 by: M. Sokolewicz
        234645 by: Jochem Maas
        234646 by: Jesper Forsberg
        234650 by: Richard Lynch

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
At 06:29 AM 4/24/2006, Philip Thompson wrote:
I think you are too kind. I think my response would have been likes
Jay's... RTFM. However, you went above and beyond. Isn't this
listserv great!! =D


Thanks, Philip. There may or may not be such a thing as stupid questions but there sure as hell are a lot of stupid answers. We all started out from places of ignorance, and there's TONS that each of us still doesn't know in a thousand fields. If I walk up to a group of geneticists and ask, "What's the difference between a chromosome and a ribosome?" I might get a laugh but I'd hope also to get pointed in the right direction. I figure all any of us need is a helpful nudge toward the documentation. "RTFM" isn't very helpful when the documentation of web design is so many millions of pages. It only takes a minute to look up the right link, especially with php.net's incredible /search engine.

If you see someone struggling up a rocky face, do you kick them or give them a boost? We know nothing about the people who post here. What kind of educational resources have we each had? And what an amazing effort to post to a technical listserve in a foreign language. I'd like to see the haughty, scornful posters on this list try their hand at asking intelligent questions in Vietnamese or Ewe.

Although I enjoy the humanistic aspect of listserves, I'm irritated when someone takes up bandwidth on the whole list just to tell someone to read the friggin manual. The folks who feel compelled to scorn others in front of the whole group are just trying to look kewl at someone else's expense. That's so high school.

I'm here for PHP. I love the wit, humor, intelligence, and passion of the list debates, but I'm working my butt off earning my living writing software and simply don't have time to scroll down through some enormous unsnipped quote simply to find "thanks!" or "you weenie!" at the bottom.

This rant is off-topic (call it "admin" if you're feeling generous) but I'm posting it to the whole list just because I think noise is a chronic problem on this listserve in particular. Please, if you just want to thank someone or tell them they're a donkey, do so privately. Serve us up the PHP!

Rushed, grumpy defender of the underdog,

Paul
--- End Message ---
--- Begin Message ---
[snip]
I'm here for PHP.  I love the wit, humor, intelligence, and passion 
of the list debates, but I'm working my butt off earning my living 
writing software and simply don't have time to scroll down through 
some enormous unsnipped quote simply to find "thanks!" or "you 
weenie!" at the bottom.
[/snip]


Whew! I snipped, bottom-posted, and included a link to a spot in the
manual where the OP could learn. I'm golden!

--- End Message ---
--- Begin Message ---
Jay Blanchard wrote:
<snip>
I'm golden!


I don't remember asking for a list of your sexual perversions.

:-p

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Another aspect is this:
Why do we call it a shopping cart?

Look, a shopping cart is a goddam big basket on wheels.

What we call a "shopping cart" on-line is actually, your entire stock
catalog, fulfillment, cash register, check-out, delivery, stock
management, and internal accounting system, with credit card POS
widgets.  And baggers.

Hey.  That ain't a "shopping cart"   That's a friggin' store.

LOL

You're absolutely right -- tho, it sounds like good stuff for a comedy routine.

tedd
--
--------------------------------------------------------------------------------
http://sperling.com

--- End Message ---
--- Begin Message ---

--- tedd <[EMAIL PROTECTED]> wrote:

Hey,


> >Hey.  That ain't a "shopping cart"   That's a
> friggin' store.
> 
> LOL
> 
> You're absolutely right -- tho, it sounds like good
> stuff for a comedy routine.

Pity it would fly over the heads of most people
though, only us "geeks" (term used loosely) would get
it, maybe at the next PHP/programming con?

------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--- End Message ---
--- Begin Message ---
[snip]
>Another aspect is this:
>Why do we call it a shopping cart?
[/snip]

We discarded this terminology in favor of 'order fulfillment system' or
OFS

--- End Message ---
--- Begin Message ---
--- Jay Blanchard <[EMAIL PROTECTED]> wrote:

> [snip]
> >Another aspect is this:
> >Why do we call it a shopping cart?
> [/snip]
> 
> We discarded this terminology in favor of 'order
> fulfillment system' or
> OFS

Man, I knew this girl some time back, she had a really
good OFS...
Oops, this might be a little off topic...hope nobody
minds ;-)

------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--- End Message ---
--- Begin Message ---
Waaait a second. You actually knew a girl who took orders?


On 4/24/06, Ryan A <[EMAIL PROTECTED]> wrote:
>
> --- Jay Blanchard <[EMAIL PROTECTED]> wrote:
>
> > [snip]
> > >Another aspect is this:
> > >Why do we call it a shopping cart?
> > [/snip]
> >
> > We discarded this terminology in favor of 'order
> > fulfillment system' or
> > OFS
>
> Man, I knew this girl some time back, she had a really
> good OFS...
> Oops, this might be a little off topic...hope nobody
> minds ;-)
>
> ------
> - The faulty interface lies between the chair and the keyboard.
> - Creativity is great, but plagiarism is faster!
> - Smile, everyone loves a moron. :-)
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
--- Tom Cruickshank <[EMAIL PROTECTED]> wrote:

> Waaait a second. You actually knew a girl who took
> orders?
 

What do you tell a girl with two black eyes? 
Nothing, coz told the b***h.... twice!


------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--- End Message ---
--- Begin Message ---
For those of you who are making a joke out of my question, glad to have 
given you all a laugh.  I want to thank everyone else for being so nice and 
helpful to beginners.
Everyone has to start somewhere and can't afford a $1000 to spend and sorry 
I'm not the "geek" you are and can write and manipulate the script.  I've 
learned so much from these newsgroups, but for some reason, a few of you 
shouldn't be so opinionated.  Don't bother to respond if you don't like the 
question.
Again, thanks to everyone else!
Lisa

""Tom Cruickshank"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
Have you checked out oscommerce? www.oscommerce.com?

It does what I think you need. And I think it might even be free, that is,
if your time
doesn't cost anything. As for it being simple....you'll need to define that
term.

Simple for me could be rather complicated for you or vice versa.

Tom




On 4/22/06, Lisa A <[EMAIL PROTECTED]> wrote:
>
> Can anyone suggest someone to write a simple client side shopping cart I
> can
> use?  I need to install something that my client can update the
> merchandise
> themselves.  Something inxepensive please.
> thanks,
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Hello,

As the %subj% says.. can't get it to work with PHP5. I mean, you could
do this kind of stuff with templates/generics on other languages and
then make a class singleton by just inheriting from base Singleton
class. No need to redefine GetInstance() (which usually contains the
same redundant kind of code). It should look something like this in
PHP5:

class Test extends Singleton
{
  // no singleton-specific code here
}

abstract class Singleton
{
  private static $instance = null;
  private function __construct() {}
  private function __clone() {}
  public static function GetInstance()
  {
    if (!isset(self::$instance))
      self::$instance = new self; // <-- doesnt really work

    return self::$instance;
  }
}

The problem is that self refers to Singleton class. I have also been
playing with __CLASS__ magic constant but it does the same thing.
Someone got it working the right way?

--- End Message ---
--- Begin Message ---
[top posting to just to spite the anti-top-posting crowd :-P]

php6 will include static late binding - until then you have 2 choices,
create a hack (see below) or stick redundant code into each class you
want to be a singleton.

(welcome to the club that thinks this should have been possible
right from the beginning - I'm a member since 2003 - it doesn't get any
less annoying ;-)

one way to hack it:

class Test extends Singleton
{       
        protected static $class = self; // if self doesn't work use 'Test'
}

abstract class Singleton
{
   private   static $instance;
   protected static $class;

   private function __construct() {}
   private function __clone() {}

   public static function GetInstance()
   {
        if (!isset(self::$instance)) {
                if (!isset(self::$class)) {
                        throw new Exception('ya need to define self::$class in 
your subclass');
                }

                self::$instance = new self::$class;
        }
        return self::$instance;
   }
}

ps - search the web for 'late static binding + php' and the like and
you'll [hopefully] find plenty in the internals mailing list archives
about this (for instance)

Simas Toleikis wrote:
Hello,

As the %subj% says.. can't get it to work with PHP5. I mean, you could
do this kind of stuff with templates/generics on other languages and
then make a class singleton by just inheriting from base Singleton
class. No need to redefine GetInstance() (which usually contains the
same redundant kind of code). It should look something like this in
PHP5:

class Test extends Singleton
{
  // no singleton-specific code here
}

abstract class Singleton
{
  private static $instance = null;
  private function __construct() {}
  private function __clone() {}
  public static function GetInstance()
  {
    if (!isset(self::$instance))
      self::$instance = new self; // <-- doesnt really work

    return self::$instance;
  }
}

The problem is that self refers to Singleton class. I have also been
playing with __CLASS__ magic constant but it does the same thing.
Someone got it working the right way?

--- End Message ---
--- Begin Message ---
> php6 will include static late binding

Great. Love the other new features, especially namespaces.

> - until then you have 2 choices,
> create a hack (see below) or stick redundant code into each class you
> want to be a singleton.

The hack doesn't work (See below). Guess we are left with copy-paste
thing :-/ Though i wonder if there are any other hacks using some sort
of classkit/other class manipulation functions?

>     public static function GetInstance()
>     {
>         if (!isset(self::$instance)) {
>                 if (!isset(self::$class)) {

Isn't that self::$class the same "late static binding" thing? :-) As i
get it, at this point from Singleton::GetInstance() you can't get the
static $class member of Test class.

--- End Message ---
--- Begin Message ---
Simas Toleikis wrote:
php6 will include static late binding


Great. Love the other new features, especially namespaces.

not sure namespaces will make it ... I believe the decision on that
is still out.



- until then you have 2 choices,
create a hack (see below) or stick redundant code into each class you
want to be a singleton.


The hack doesn't work (See below). Guess we are left with copy-paste

my bad - I was thinking out loud and didn't check. here is a less elegant
hack that does get some of the way to where you want to be (take
a look at what happens if you set Singleton::__construct() as private -
you get a weird error, which to me smell like a bug - but then again there
is some logic to it, although I wonder if it's intended)
:

<?php
class Test extends Singleton
{
    static public function getInstance()
    {
        return self::_getInstance(__CLASS__);
    }
}

abstract class Singleton
{
    private   static $instance;

    protected function __construct() {}
    private function __clone() {}

    abstract static public function getInstance();

    protected static function _getInstance($c)
    {
        if (!isset(self::$instance)) {
            self::$instance = new $c;
        }
        return self::$instance;
    }
}

var_dump( Test::getInstance() );
?>

thing :-/ Though i wonder if there are any other hacks using some sort
of classkit/other class manipulation functions?

probably runkit (or is it classkit - can't remember which of those
is more actively developed) might give a way out - but I would recommend
it for production code.



   public static function GetInstance()
   {
       if (!isset(self::$instance)) {
               if (!isset(self::$class)) {


Isn't that self::$class the same "late static binding" thing? :-) As i

yeah - put it down to a thinko.

get it, at this point from Singleton::GetInstance() you can't get the
static $class member of Test class.

--- End Message ---
--- Begin Message ---
Hello,

The site I'm working on works like this...
Requires a login that uses sessions to remember username and email address. Upon being verified, the user is presented with a page that displays several questions regarding their background. Upon submitting the background page, a script checks to make sure all background questions were answered. If not, the page is redisplayed with a warning to answer all questions. If they are all present, a second page is displayed asking about a specific topic. Submitting the second page calls up the code provided below.

In reading the www.php.net/manual/en/ref.session.php page, I'd like to point out we do not use cookies. The session id is propagated in the URL (although it's not visible in the URL bar). Also, session.gc_maxlifetime is set to 5400. We are using PHP 4.3.4.

Not very often, but once in a while, I'll get an email warning me that a submission was denied because $_SESSION['Q'] is empty. I'm wondering, hoping and/or praying that someone out there can look at this small script and let me know if I'm doing something wrong with the built in function array_pop, perhaps I don't understand sessions at all or perhaps it is a server issue. It's very confusing because other session variables (name and email from the login page) are not emptied, just $_SESSION['Q'].

Here's my code with some documentation:
<?php
/*
$_SESSION['startQA'] contains 11 elements and is generated by a previous page in the site. Once the visitor clicks the page two submit button, the above SESSION variable comes into play again.

This script takes that array of elements and does the following:
1. Assign session array to local array
2. Removes the last elemental value using array_pop
3. Removes the last elemental value using array_pop
4. Assign local variable the value of the a POST element
4a. Create a new session array and populates the first element equal to POST element
5. Runs through and populates the remaining 9 elements
5a. Total of 10 elements are now populated, 0 thru 9
6. Double checks the existence of each element
6a. if an element is missing, email me a warning and end program
*/

//Assign Session array to local variable
// Step 1
$thisQarray = $_SESSION['startQA'];

//Remove the last element of the original array
// Step 2
$area = array_pop($thisQarray);

//Remove last element of bgq array and assign to taking_test_at
// Step 3
$from_location = array_pop($thisQarray);

//Assign test version to variable
// Step 4
$testVersion = $_POST['version'];

//Start building the final Session Array
// Step 4a
$_SESSION['Q'] = array($testVersion);

//Populate rest of Session Array
// Step 5
for ($newBGQCounter=0; $newBGQCounter<count($thisQarray); $newBGQCounter++)
{
 $_SESSION['Q'][$newBGQCounter+1] = $thisQarray[$newBGQCounter];
}

//test for existense of session array elements
if ( ($_SESSION['Q'][0] == "") OR ($_SESSION['Q'][1] == "") OR ($_SESSION['Q'][2] == "") OR ($_SESSION['Q'][3] == "") OR ($_SESSION['Q'][4] == "") OR ($_SESSION['Q'][5] == "") OR ($_SESSION['Q'][6] == "") OR ($_SESSION['Q'][7] == "") OR ($_SESSION['Q'][8] == "") OR ($_SESSION['Q'][9] == "") )
{
 SEND ME AN ERROR EMAIL
 END PROGRAM
}
?>

Thank you all very much,
R

--- End Message ---
--- Begin Message ---
You're missing the session_start() call at the beginning of your code.
I'm surprised it works at all without that..

http://www.php.net/manual/en/ref.session.php
http://www.php.net/manual/en/function.session-start.php


Brady


> -----Original Message-----
> From: Webmaster [mailto:[EMAIL PROTECTED] 
> Sent: Monday, April 24, 2006 1:49 PM
> To: php-general@lists.php.net
> Subject: [PHP] Session Array Disappears
> 
> Hello,
> 
> The site I'm working on works like this...
> Requires a login that uses sessions to remember username and email 
> address.  Upon being verified, the user is presented with a page that 
> displays several questions regarding their background.  Upon 
> submitting 
> the background page, a script checks to make sure all background 
> questions were answered.  If not, the page is redisplayed 
> with a warning 
> to answer all questions.  If they are all present, a second page is 
> displayed asking about a specific topic.  Submitting the second page 
> calls up the code provided below.
> 
> In reading the www.php.net/manual/en/ref.session.php page, 
> I'd like to 
> point out we do not use cookies.  The session id is propagated in the 
> URL (although it's not visible in the URL bar).  Also, 
> session.gc_maxlifetime is set to 5400.  We are using PHP 4.3.4.
> 
> Not very often, but once in a while, I'll get an email 
> warning me that a 
> submission was denied because $_SESSION['Q'] is empty.  I'm 
> wondering, 
> hoping and/or praying that someone out there can look at this small 
> script and let me know if I'm doing something wrong with the built in 
> function array_pop, perhaps I don't understand sessions at all or 
> perhaps it is a server issue.  It's very confusing because 
> other session 
> variables (name and email from the login page) are not emptied, just 
> $_SESSION['Q'].
> 
> Here's my code with some documentation:
> <?php
> /*
> $_SESSION['startQA'] contains 11 elements and is generated by 
> a previous 
> page in the site.
> Once the visitor clicks the page two submit button, the above SESSION 
> variable comes into play again.
> 
> This script takes that array of elements and does the following:
> 1. Assign session array to local array
> 2. Removes the last elemental value using array_pop
> 3. Removes the last elemental value using array_pop
> 4. Assign local variable the value of the a POST element
> 4a. Create a new session array and populates the first 
> element equal to 
> POST element
> 5. Runs through and populates the remaining 9 elements
> 5a. Total of 10 elements are now populated, 0 thru 9
> 6. Double checks the existence of each element
> 6a. if an element is missing, email me a warning and end program
> */
> 
> //Assign Session array to local variable
> // Step 1
> $thisQarray = $_SESSION['startQA'];
>  
> //Remove the last element of the original array
> // Step 2
> $area = array_pop($thisQarray);
>  
> //Remove last element of bgq array and assign to taking_test_at
> // Step 3
> $from_location = array_pop($thisQarray);
>  
> //Assign test version to variable
> // Step 4
> $testVersion = $_POST['version'];
> 
> //Start building the final Session Array
> // Step 4a
> $_SESSION['Q'] = array($testVersion);
> 
> //Populate rest of Session Array
> // Step 5
> for ($newBGQCounter=0; $newBGQCounter<count($thisQarray); 
> $newBGQCounter++)
> {
>   $_SESSION['Q'][$newBGQCounter+1] = $thisQarray[$newBGQCounter];
> }
>  
> //test for existense of session array elements
> if ( ($_SESSION['Q'][0] == "") OR ($_SESSION['Q'][1] == "") OR 
> ($_SESSION['Q'][2] == "") OR ($_SESSION['Q'][3] == "") OR 
> ($_SESSION['Q'][4] == "") OR ($_SESSION['Q'][5] == "") OR 
> ($_SESSION['Q'][6] == "") OR ($_SESSION['Q'][7] == "") OR 
> ($_SESSION['Q'][8] == "") OR ($_SESSION['Q'][9] == "") )
> {
>   SEND ME AN ERROR EMAIL
>   END PROGRAM
> }
> ?>
> 
> Thank you all very much,
> R
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

--- End Message ---
--- Begin Message ---
Thanks for the reply.

Sorry, that was a typo in the email. I actually do have session_start(); at the beginning of the scripts. My bad.

Thanks,
R

Brady Mitchell wrote:
You're missing the session_start() call at the beginning of your code.
I'm surprised it works at all without that..

http://www.php.net/manual/en/ref.session.php
http://www.php.net/manual/en/function.session-start.php


Brady


-----Original Message-----
From: Webmaster [mailto:[EMAIL PROTECTED] Sent: Monday, April 24, 2006 1:49 PM
To: php-general@lists.php.net
Subject: [PHP] Session Array Disappears

Hello,

The site I'm working on works like this...
Requires a login that uses sessions to remember username and email address. Upon being verified, the user is presented with a page that displays several questions regarding their background. Upon submitting the background page, a script checks to make sure all background questions were answered. If not, the page is redisplayed with a warning to answer all questions. If they are all present, a second page is displayed asking about a specific topic. Submitting the second page calls up the code provided below.

In reading the www.php.net/manual/en/ref.session.php page, I'd like to point out we do not use cookies. The session id is propagated in the URL (although it's not visible in the URL bar). Also, session.gc_maxlifetime is set to 5400. We are using PHP 4.3.4.

Not very often, but once in a while, I'll get an email warning me that a submission was denied because $_SESSION['Q'] is empty. I'm wondering, hoping and/or praying that someone out there can look at this small script and let me know if I'm doing something wrong with the built in function array_pop, perhaps I don't understand sessions at all or perhaps it is a server issue. It's very confusing because other session variables (name and email from the login page) are not emptied, just $_SESSION['Q'].

Here's my code with some documentation:
<?php
/*
$_SESSION['startQA'] contains 11 elements and is generated by a previous page in the site. Once the visitor clicks the page two submit button, the above SESSION variable comes into play again.

This script takes that array of elements and does the following:
1. Assign session array to local array
2. Removes the last elemental value using array_pop
3. Removes the last elemental value using array_pop
4. Assign local variable the value of the a POST element
4a. Create a new session array and populates the first element equal to POST element
5. Runs through and populates the remaining 9 elements
5a. Total of 10 elements are now populated, 0 thru 9
6. Double checks the existence of each element
6a. if an element is missing, email me a warning and end program
*/

//Assign Session array to local variable
// Step 1
$thisQarray = $_SESSION['startQA'];
//Remove the last element of the original array
// Step 2
$area = array_pop($thisQarray);
//Remove last element of bgq array and assign to taking_test_at
// Step 3
$from_location = array_pop($thisQarray);
//Assign test version to variable
// Step 4
$testVersion = $_POST['version'];

//Start building the final Session Array
// Step 4a
$_SESSION['Q'] = array($testVersion);

//Populate rest of Session Array
// Step 5
for ($newBGQCounter=0; $newBGQCounter<count($thisQarray); $newBGQCounter++)
{
  $_SESSION['Q'][$newBGQCounter+1] = $thisQarray[$newBGQCounter];
}
//test for existense of session array elements if ( ($_SESSION['Q'][0] == "") OR ($_SESSION['Q'][1] == "") OR ($_SESSION['Q'][2] == "") OR ($_SESSION['Q'][3] == "") OR ($_SESSION['Q'][4] == "") OR ($_SESSION['Q'][5] == "") OR ($_SESSION['Q'][6] == "") OR ($_SESSION['Q'][7] == "") OR ($_SESSION['Q'][8] == "") OR ($_SESSION['Q'][9] == "") )
{
  SEND ME AN ERROR EMAIL
  END PROGRAM
}
?>

Thank you all very much,
R

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






--- End Message ---
--- Begin Message ---
add a ignore_user_abort(TRUE) first thing in your code.

Webmaster wrote:
Thanks for the reply.

Sorry, that was a typo in the email. I actually do have session_start(); at the beginning of the scripts. My bad.

Thanks,
R

Brady Mitchell wrote:
You're missing the session_start() call at the beginning of your code.
I'm surprised it works at all without that..

http://www.php.net/manual/en/ref.session.php
http://www.php.net/manual/en/function.session-start.php


Brady


-----Original Message-----
From: Webmaster [mailto:[EMAIL PROTECTED] Sent: Monday, April 24, 2006 1:49 PM
To: php-general@lists.php.net
Subject: [PHP] Session Array Disappears

Hello,

The site I'm working on works like this...
Requires a login that uses sessions to remember username and email address. Upon being verified, the user is presented with a page that displays several questions regarding their background. Upon submitting the background page, a script checks to make sure all background questions were answered. If not, the page is redisplayed with a warning to answer all questions. If they are all present, a second page is displayed asking about a specific topic. Submitting the second page calls up the code provided below.

In reading the www.php.net/manual/en/ref.session.php page, I'd like to point out we do not use cookies. The session id is propagated in the URL (although it's not visible in the URL bar). Also, session.gc_maxlifetime is set to 5400. We are using PHP 4.3.4.

Not very often, but once in a while, I'll get an email warning me that a submission was denied because $_SESSION['Q'] is empty. I'm wondering, hoping and/or praying that someone out there can look at this small script and let me know if I'm doing something wrong with the built in function array_pop, perhaps I don't understand sessions at all or perhaps it is a server issue. It's very confusing because other session variables (name and email from the login page) are not emptied, just $_SESSION['Q'].

Here's my code with some documentation:
<?php
/*
$_SESSION['startQA'] contains 11 elements and is generated by a previous page in the site. Once the visitor clicks the page two submit button, the above SESSION variable comes into play again.

This script takes that array of elements and does the following:
1. Assign session array to local array
2. Removes the last elemental value using array_pop
3. Removes the last elemental value using array_pop
4. Assign local variable the value of the a POST element
4a. Create a new session array and populates the first element equal to POST element
5. Runs through and populates the remaining 9 elements
5a. Total of 10 elements are now populated, 0 thru 9
6. Double checks the existence of each element
6a. if an element is missing, email me a warning and end program
*/

//Assign Session array to local variable
// Step 1
$thisQarray = $_SESSION['startQA'];
//Remove the last element of the original array
// Step 2
$area = array_pop($thisQarray);
//Remove last element of bgq array and assign to taking_test_at
// Step 3
$from_location = array_pop($thisQarray);
//Assign test version to variable
// Step 4
$testVersion = $_POST['version'];

//Start building the final Session Array
// Step 4a
$_SESSION['Q'] = array($testVersion);

//Populate rest of Session Array
// Step 5
for ($newBGQCounter=0; $newBGQCounter<count($thisQarray); $newBGQCounter++)
{
  $_SESSION['Q'][$newBGQCounter+1] = $thisQarray[$newBGQCounter];
}
//test for existense of session array elements if ( ($_SESSION['Q'][0] == "") OR ($_SESSION['Q'][1] == "") OR ($_SESSION['Q'][2] == "") OR ($_SESSION['Q'][3] == "") OR ($_SESSION['Q'][4] == "") OR ($_SESSION['Q'][5] == "") OR ($_SESSION['Q'][6] == "") OR ($_SESSION['Q'][7] == "") OR ($_SESSION['Q'][8] == "") OR ($_SESSION['Q'][9] == "") )
{
  SEND ME AN ERROR EMAIL
  END PROGRAM
}
?>

Thank you all very much,
R

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






--- End Message ---
--- Begin Message ---
Hello,

Thank you for the reply.

Interesting function. I have not heard of that one previously. I've read the manual pages for it.....If I understand ignore_user_abort(TRUE)...you are thinking that maybe the user is being disconnected (using stop button or having ISP issues) prior to the script finishing and therefore the script does not have a chance to create the array? I'm wondering if that would be true, since later in the same script, it generates an email to inform me someone's submission was lost because the array did not exist. I'm confused how it could stop executing the middle of the script (step 4a and 5 below) but yet execute the end of the script (the final step in the code below)? I was first made aware of this issue because of the email, so I think the end of the script is executing.

Thanks,
R

Al wrote:
add a ignore_user_abort(TRUE) first thing in your code.
Hello,

The site I'm working on works like this...
Requires a login that uses sessions to remember username and email address. Upon being verified, the user is presented with a page that displays several questions regarding their background. Upon submitting the background page, a script checks to make sure all background questions were answered. If not, the page is redisplayed with a warning to answer all questions. If they are all present, a second page is displayed asking about a specific topic. Submitting the second page calls up the code provided below.

In reading the www.php.net/manual/en/ref.session.php page, I'd like to point out we do not use cookies. The session id is propagated in the URL (although it's not visible in the URL bar). Also, session.gc_maxlifetime is set to 5400. We are using PHP 4.3.4.

Not very often, but once in a while, I'll get an email warning me that a submission was denied because $_SESSION['Q'] is empty. I'm wondering, hoping and/or praying that someone out there can look at this small script and let me know if I'm doing something wrong with the built in function array_pop, perhaps I don't understand sessions at all or perhaps it is a server issue. It's very confusing because other session variables (name and email from the login page) are not emptied, just $_SESSION['Q'].

Here's my code with some documentation:
<?php
/*
$_SESSION['startQA'] contains 11 elements and is generated by a previous page in the site. Once the visitor clicks the page two submit button, the above SESSION variable comes into play again.

This script takes that array of elements and does the following:
1. Assign session array to local array
2. Removes the last elemental value using array_pop
3. Removes the last elemental value using array_pop
4. Assign local variable the value of the a POST element
4a. Create a new session array and populates the first element equal to POST element
5. Runs through and populates the remaining 9 elements
5a. Total of 10 elements are now populated, 0 thru 9
6. Double checks the existence of each element
6a. if an element is missing, email me a warning and end program
*/

//Assign Session array to local variable
// Step 1
$thisQarray = $_SESSION['startQA'];
//Remove the last element of the original array
// Step 2
$area = array_pop($thisQarray);
//Remove last element of bgq array and assign to taking_test_at
// Step 3
$from_location = array_pop($thisQarray);
//Assign test version to variable
// Step 4
$testVersion = $_POST['version'];

//Start building the final Session Array
// Step 4a
$_SESSION['Q'] = array($testVersion);

//Populate rest of Session Array
// Step 5
for ($newBGQCounter=0; $newBGQCounter<count($thisQarray); $newBGQCounter++)
{
  $_SESSION['Q'][$newBGQCounter+1] = $thisQarray[$newBGQCounter];
}
//test for existense of session array elements if ( ($_SESSION['Q'][0] == "") OR ($_SESSION['Q'][1] == "") OR ($_SESSION['Q'][2] == "") OR ($_SESSION['Q'][3] == "") OR ($_SESSION['Q'][4] == "") OR ($_SESSION['Q'][5] == "") OR ($_SESSION['Q'][6] == "") OR ($_SESSION['Q'][7] == "") OR ($_SESSION['Q'][8] == "") OR ($_SESSION['Q'][9] == "") )
{
  SEND ME AN ERROR EMAIL
  END PROGRAM
}
?>

--- End Message ---
--- Begin Message ---
Hello,

==
<?php
$name = 'foo bar';

echo "<a href=/index.php?name=". $name .">Foo Bar</a>";
?>
==

Then the URL showed up at the bottom border of the browser has 'name=foo'.

What should I do to have 'name=foo bar' in the URL?  I tried
htmlspecialchars but did not see any difference.

I'd appreciate any help.

Bing

--- End Message ---
--- Begin Message ---
http://php.net/manual/en/function.urlencode.php

Should get you what you need :)

Dan

-- 
http://chrome.me.uk
 
-----Original Message-----
From: Bing Du [mailto:[EMAIL PROTECTED] 
Sent: 24 April 2006 22:42
To: php-general@lists.php.net
Subject: [PHP] how to keep spaces in parameters in URL?

Hello,

==
<?php
$name = 'foo bar';

echo "<a href=/index.php?name=". $name .">Foo Bar</a>";
?>
==

Then the URL showed up at the bottom border of the browser has 'name=foo'.

What should I do to have 'name=foo bar' in the URL?  I tried
htmlspecialchars but did not see any difference.

I'd appreciate any help.

Bing

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


__________ NOD32 1.1504 (20060424) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com

--- End Message ---
--- Begin Message ---
 
Try
print("<a href='/index.php?name=$name'>Foo Bar</a>");


Jeremy Schreckhise, M.B.A.


Hello,

==
<?php
$name = 'foo bar';

echo "<a href=/index.php?name=". $name .">Foo Bar</a>"; ?> ==

Then the URL showed up at the bottom border of the browser has 'name=foo'.

What should I do to have 'name=foo bar' in the URL?  I tried
htmlspecialchars but did not see any difference.

I'd appreciate any help.

Bing

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

--- End Message ---
--- Begin Message ---
Hello,

I've seen the usage of both TRUE, true, FALSE and false all over the
php.net site. Yet, there does not seem to be a clear distinction
between the uppercase and lowercase variants.

Will it make any difference if i use lowercase or uppercase?
I would be thankful if someone could shed some light on this.

Kindest regards,
Jesper

--- End Message ---
--- Begin Message ---
Jesper Forsberg wrote:
Hello,

I've seen the usage of both TRUE, true, FALSE and false all over the
php.net site. Yet, there does not seem to be a clear distinction
between the uppercase and lowercase variants.

Will it make any difference if i use lowercase or uppercase?
I would be thankful if someone could shed some light on this.

Kindest regards,
Jesper

PHP keywords are case-insensitive. Since true and false fall under this category, so are they. Don't worry, it won't make any difference (unless you have strict coding guidelines, which restrict you to a single type of use...)

- tul

--- End Message ---
--- Begin Message ---
M. Sokolewicz wrote:
Jesper Forsberg wrote:

Hello,

I've seen the usage of both TRUE, true, FALSE and false all over the
php.net site. Yet, there does not seem to be a clear distinction
between the uppercase and lowercase variants.

Will it make any difference if i use lowercase or uppercase?
I would be thankful if someone could shed some light on this.

Kindest regards,
Jesper


PHP keywords are case-insensitive. Since true and false fall under this category, so are they. Don't worry, it won't make any difference (unless you have strict coding guidelines, which restrict you to a single type of use...)

actually even then it doesn't make a difference to the php engine - granted
your company's CS gestapo might pay you a visit if you don't comply ;-)


- tul


--- End Message ---
--- Begin Message ---
Thank you very much. You've been most helpful :)

On 4/25/06, Jochem Maas <[EMAIL PROTECTED]> wrote:
> M. Sokolewicz wrote:
> > Jesper Forsberg wrote:
> >
> >> Hello,
> >>
> >> I've seen the usage of both TRUE, true, FALSE and false all over the
> >> php.net site. Yet, there does not seem to be a clear distinction
> >> between the uppercase and lowercase variants.
> >>
> >> Will it make any difference if i use lowercase or uppercase?
> >> I would be thankful if someone could shed some light on this.
> >>
> >> Kindest regards,
> >> Jesper
> >
> >
> > PHP keywords are case-insensitive. Since true and false fall under this
> > category, so are they. Don't worry, it won't make any difference (unless
> > you have strict coding guidelines, which restrict you to a single type
> > of use...)
>
> actually even then it doesn't make a difference to the php engine - granted
> your company's CS gestapo might pay you a visit if you don't comply ;-)
>
> >
> > - tul
> >
>
>

--- End Message ---
--- Begin Message ---
On Mon, April 24, 2006 5:12 pm, Jesper Forsberg wrote:
> I've seen the usage of both TRUE, true, FALSE and false all over the
> php.net site. Yet, there does not seem to be a clear distinction
> between the uppercase and lowercase variants.
>
> Will it make any difference if i use lowercase or uppercase?
> I would be thankful if someone could shed some light on this.

You *do* want to stay consistent with whatever you choose -- or with
whatever was chosen by the developer of the code you inherited.

Unless they were totally wacko and used TrUe and fAlSe :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---

Reply via email to