[phplib] logic error in add_query() From: Spruce Weber (sprucely <email protected>)
Date: 07/02/00

I was having a problem (in cookie mode only) where add_query() would
sometimes place "?" where it was needed and sometimes wouldn't. I figured
out that it was any page called with a QUERY_STRING already set in which it
would fail. The checking of $QUERY_STRING is needed in the function
self_url() so that it can be put back into the URL. This check shouldn't be
in add_query() because having a non-empty $QUERY_STRING doesn't mean its
contents is going to appear in the URLs on that page. I made the following
modifications and everything is now working fine in both get and cookie
mode...

  function add_query($qarray) {
    global $PHP_SELF;
    global $QUERY_STRING;

- if ((isset($QUERY_STRING) && ("" != $QUERY_STRING))
- || ($this->mode == "get")) {
+ if ($this->mode == "get") {
      $sep_char = "&";
    } else {
      $sep_char = "?";
    }

    $qstring = "";
    while (list($k, $v) = each($qarray)) {
      $qstring .= $sep_char . urlencode($k) . "=" . urlencode($v);
      $sep_char = "&";
    }

    return $qstring;
  }

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>