php-general Digest 30 Jun 2002 13:48:29 -0000 Issue 1436

Topics (messages 104544 through 104572):

Re: Usiing FOREACH to loop through Array
        104544 by: Brad Melendy
        104548 by: Steve Edberg
        104550 by: Brad Melendy

mcrypt
        104545 by: charlesk

Re: Getting IP from behind proxies
        104546 by: JJ Harrison
        104547 by: Rasmus Lerdorf

Re: Limiting number of decimal places reported
        104549 by: Beverly Steiner

Re: pop-up windows
        104551 by: Justin French

Re: Keeping "Secrets" in PHP Files
        104552 by: Justin French

Re: supersession
        104553 by: Justin French

Re: Yet another session problem, with a twist.
        104554 by: Justin French

[Session] SID automatically add on all pages?
        104555 by: Tim Stoop
        104561 by: Justin French
        104562 by: Tim Stoop
        104566 by: Justin French
        104569 by: Jason Wong
        104570 by: Tim Stoop

Two cases going to same case?
        104556 by: Leif K-Brooks
        104559 by: Steve Edberg
        104565 by: Tom Rogers

Blank emails
        104557 by: César Aracena
        104560 by: Peter

ZIP combinaton in PHP?
        104558 by: Tony Harrison
        104568 by: Jason Wong

bug in sessions
        104563 by: Michal Dvoracek

include files or fopen
        104564 by: Lee

Re: Populate Popup Menu from Database
        104567 by: Jason Wong

Re: change variable in file
        104571 by: Jason Wong

imageellipse not working with gdlib2.0
        104572 by: William S.

Administrivia:

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

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

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Steve,
Thanks very much.  This make total sense to me.  Now, I was pretty sure that
I was getting an array back from mysql_fetch_array because when I do a
'print $myCourses' without specifying any value, I just get 'array' which I
believe I am supposed to, IF it is truly an array.  Anyway, I'm going to
revisit the mysql_fetch_array function right now.  Thanks for your help, it
is greatly appreciated.

...Brad

"Steve Edberg" <[EMAIL PROTECTED]> wrote in message
news:p05100300b943f2a7feef@[168.150.239.37]...
> At 3:27 PM -0700 6/29/02, Brad Melendy wrote:
> >Hi All,
> >I've stumped myself here.  In a nutshell, I have a function that returns
my
> >array based on a SQL query and here's the code:
> >
> >-------------begin code-------------------
> >function getCourses($UID)
> >  {
> >  global $link;
> >  $result = mysql_query( "SELECT C.CourseName FROM tblcourses C, tblusers
U,
> >tblEnrollment E WHERE C.ID = E.CourseID AND E.UserID = U.ID AND U.ID =
> >$UID", $link );
> >  if ( ! $result )
> >   die ( "getRow fatal error: ".mysql_error() );
> >  return mysql_fetch_array( $result );
> >  }
> >------------end code ----------------
> >
> >I call this from a PHP page with the following code:
> >
> >------------begin code--------------
> >$myCourses = getCourses($session[id]);
> >foreach ($myCourses as $value)
> >  {
> >  print "<br>$value";
> >  }
> >------------end code---------------
> >
> >Now, when I test the SQL from my function directly on the database, it
> >returns just want I want it to return but it isn't working that way on my
> >PHP page. For results where there is a single entry, I am getting the
same
> >entry TWICE and for records with more than a single entry I am getting
ONLY
> >the FIRST entry TWICE.
> >
> >Now I know my SQL code is correct (I am testing it against a MySQL
database
> >using MySQL-Front) so I suspect I'm doing something stupid in my foreach
> >loop.
>
>
> I think your problem lies in a misunderstanding of the
> mysql_fetch_array() function. It doesn't return the entire result set
> in an array - just one record at a time. You can fix this in one of
> two ways:
>
> (1) Loop though the entire result set in your function:
>
>     function getCourses($UID)
>      {
>       global $link;
>
>       $ResultSet = array();
>
>       $result = mysql_query( "SELECT C.CourseName FROM tblcourses C,
tblusers U,
>        tblEnrollment E WHERE C.ID = E.CourseID AND E.UserID = U.ID AND
U.ID =
>        $UID", $link );
>
>       if ( ! $result )
>        die ( "getRow fatal error: ".mysql_error() );
>
>       while ($Row = mysql_fetch_array( $result ))
>       {
>        $ResultSet[] = $Row['C.CourseName'];
>       }
>
>       return $ResultSet;
>      }
>
>     ...
>
>     $myCourses = getCourses($session[id]);
>     foreach ($myCourses as $value)
>      {
>      print "<br>$value";
>      }
>
> or (2) set a flag in getCourses() so that the query is only executed
> once, otherwise returning a result line - something like:
>
>     function getCourses($UID)
>      global $link;
>      static $result = false;
>
>      if (!$result)
>       {
>         $result = mysql_query( "SELECT C.CourseName FROM tblcourses C,
> tblusers U,
>          tblEnrollment E WHERE C.ID = E.CourseID AND E.UserID = U.ID AND
U.ID =
>          $UID", $link );
>         if ( ! $result )
>          die ( "getRow fatal error: ".mysql_error() );
>       }
>      {
>      return mysql_fetch_array( $result );
>      }
>
>     ...
>
>     while ($Row = getCourses($session[id]) as $value)
>      {
>      print "<br>", $Row['C.CourseName'];
>      }
>
> (standard caveats about off-top-of-head, untested code apply)
>
> The reason you are getting the first record TWICE is becaouse of the
> default behaviour of the mysql_fetch_array() function. It returns
> both an associative array - ie, elements of the form <field-name> =>
> <value> - and a numerically indexed array (0, 1, 2, etc.). You can
> alter this behaviour by the second parameter of the function: see
>
> http://www.php.net/manual/en/function.mysql-fetch-array.php
>
> -steve
>
>
> >I'm hoping someone will spot my dumb mistake.  Thanks very much for any
help
> >at all on this.
> >
> >....Brad
> >
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --
> +------------------------------------------------------------------------+
> | Steve Edberg                                      [EMAIL PROTECTED] |
> | University of California, Davis                          (530)754-9127 |
> | Programming/Database/SysAdmin               http://pgfsun.ucdavis.edu/ |
> +------------------------------------------------------------------------+
> | The end to politics as usual:                                          |
> |                 The Monster Raving Loony Party (http://www.omrlp.com/) |
> +------------------------------------------------------------------------+


--- End Message ---
--- Begin Message ---
At 7:35 PM -0700 6/29/02, Brad Melendy wrote:
>Steve,
>Thanks very much.


You're welcome!


>This make total sense to me.  Now, I was pretty sure that
>I was getting an array back from mysql_fetch_array because when I do a
>'print $myCourses' without specifying any value, I just get 'array' which I
>believe I am supposed to, IF it is truly an array.  Anyway, I'm going to
>revisit the mysql_fetch_array function right now.  Thanks for your help, it
>is greatly appreciated.
>
>...Brad


Just to clarify a bit - mysql_fetch_array() DOES return an array - 
thus the name - but it is an array containing one record from the 
result set. For instance, if the result of the statement

    SELECT C.CourseName
    FROM tblcourses C, tblusers U, tblEnrollment E
    WHERE C.ID = E.CourseID AND E.UserID = U.ID AND U.ID = 1

through the MySQL commandline was

    +-----------------+
    | C.CourseName    |
    +-----------------+
    | Basketweaving   |
    | Noodle twirling |
    | Poodle furling  |
    | Puddle curling  |
    +-----------------+

then the first use of mysql_fetch_array($result) through PHP would 
retrieve the array

    'C.CourseName' => 'Basketweaving',
    0 => 'Basketweaving'

the second call would retrieve

    'C.CourseName' => ' Noodle twirling',
    0 => ' Noodle twirling'

and so on. If you had two columns in the result set:

    +-----------------+------------+
    | C.CourseName    | C.CourseNo |
    +-----------------+------------+
    | Basketweaving   | 12         |
    | Noodle twirling | 23         |
    | Poodle furling  | 24         |
    | Puddle curling  | 25         |
    +-----------------+------------+

you would get results like

    'C.CourseName' => 'Basketweaving',
    0 => 'Basketweaving',
    'C.CourseNo' => 12,
    1 => 12

and so on. The reason you get the doubled keys (associative & 
numeric) is for historical compatibility; to turn off the feature, 
and retrieve only the associated indexes (the behavior you normally 
want), you can use

    mysql_fetch_array($result, MYSQL_ASSOC);

Incidentally, I just learned something here myself; there's a 
relatively new (>= version 4.0.3) function mysql_fetch_assoc() which 
does what you want...return ONLY the associated indexes. See:

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


-steve



>"Steve Edberg" <[EMAIL PROTECTED]> wrote in message
>news:p05100300b943f2a7feef@[168.150.239.37]...
>>  At 3:27 PM -0700 6/29/02, Brad Melendy wrote:
>>  >Hi All,
>>  >I've stumped myself here.  In a nutshell, I have a function that returns
>my
>>  >array based on a SQL query and here's the code:
>>  >
>>  >-------------begin code-------------------
>>  >function getCourses($UID)
>>  >  {
>>  >  global $link;
>  > >  $result = mysql_query( "SELECT C.CourseName FROM tblcourses C, tblusers
>U,
>>  >tblEnrollment E WHERE C.ID = E.CourseID AND E.UserID = U.ID AND U.ID =
>  > >$UID", $link );
>>  >  if ( ! $result )
>>  >   die ( "getRow fatal error: ".mysql_error() );
>>  >  return mysql_fetch_array( $result );
>>  >  }
>>  >------------end code ----------------
>>  >
>>  >I call this from a PHP page with the following code:
>>  >
>>  >------------begin code--------------
>>  >$myCourses = getCourses($session[id]);
>>  >foreach ($myCourses as $value)
>>  >  {
>>  >  print "<br>$value";
>>  >  }
>>  >------------end code---------------
>>  >
>>  >Now, when I test the SQL from my function directly on the database, it
>>  >returns just want I want it to return but it isn't working that way on my
>>  >PHP page. For results where there is a single entry, I am getting the
>same
>>  >entry TWICE and for records with more than a single entry I am getting
>ONLY
>>  >the FIRST entry TWICE.
>>  >
>>  >Now I know my SQL code is correct (I am testing it against a MySQL
>database
>>  >using MySQL-Front) so I suspect I'm doing something stupid in my foreach
>>  >loop.
>>
>>
>>  I think your problem lies in a misunderstanding of the
>>  mysql_fetch_array() function. It doesn't return the entire result set
>  > in an array - just one record at a time. You can fix this in one of
>>  two ways:
>>
>>  (1) Loop though the entire result set in your function:
>>
>>      function getCourses($UID)
>>       {
>>        global $link;
>>
>>        $ResultSet = array();
>>
>>        $result = mysql_query( "SELECT C.CourseName FROM tblcourses C,
>tblusers U,
>>         tblEnrollment E WHERE C.ID = E.CourseID AND E.UserID = U.ID AND
>U.ID =
>>         $UID", $link );
>>
>>        if ( ! $result )
>>         die ( "getRow fatal error: ".mysql_error() );
>>
>>        while ($Row = mysql_fetch_array( $result ))
>>        {
>>         $ResultSet[] = $Row['C.CourseName'];
>>        }
>>
>>        return $ResultSet;
>>       }
>>
>>      ...
>>
>>      $myCourses = getCourses($session[id]);
>>      foreach ($myCourses as $value)
>>       {
>>       print "<br>$value";
>>       }
>>
>>  or (2) set a flag in getCourses() so that the query is only executed
>>  once, otherwise returning a result line - something like:
>>
>>      function getCourses($UID)
>>       global $link;
>>       static $result = false;
>>
>>       if (!$result)
>>        {
>>          $result = mysql_query( "SELECT C.CourseName FROM tblcourses C,
>>  tblusers U,
>>           tblEnrollment E WHERE C.ID = E.CourseID AND E.UserID = U.ID AND
>U.ID =
>>           $UID", $link );
>>          if ( ! $result )
>>           die ( "getRow fatal error: ".mysql_error() );
>>        }
>>       {
>>       return mysql_fetch_array( $result );
>>       }
>>
>>      ...
>>
>>      while ($Row = getCourses($session[id]) as $value)
>>       {
>>       print "<br>", $Row['C.CourseName'];
>>       }
>>
>>  (standard caveats about off-top-of-head, untested code apply)
>>
>>  The reason you are getting the first record TWICE is becaouse of the
>>  default behaviour of the mysql_fetch_array() function. It returns
>>  both an associative array - ie, elements of the form <field-name> =>
>>  <value> - and a numerically indexed array (0, 1, 2, etc.). You can
>>  alter this behaviour by the second parameter of the function: see
>>
>>  http://www.php.net/manual/en/function.mysql-fetch-array.php
>>
>  > -steve


-- 
+------------------------------------------------------------------------+
| Steve Edberg                                      [EMAIL PROTECTED] |
| University of California, Davis                          (530)754-9127 |
| Programming/Database/SysAdmin               http://pgfsun.ucdavis.edu/ |
+------------------------------------------------------------------------+
| The end to politics as usual:                                          |
|                 The Monster Raving Loony Party (http://www.omrlp.com/) |
+------------------------------------------------------------------------+
--- End Message ---
--- Begin Message ---
Steve,
Thanks a ton!  I'm now running slick as a whistle using your option #1
(looping through the results in the function) and using the newer
mysql_fetch_assoc() function.  I have a much better understanding of this
now and I really appreciate your help.  Hopefully I'll get a chance to help
someone else next time.  :-)

"Steve Edberg" <[EMAIL PROTECTED]> wrote in message
news:p05100300b943f2a7feef@[168.150.239.37]...
> At 3:27 PM -0700 6/29/02, Brad Melendy wrote:
> >Hi All,
> >I've stumped myself here.  In a nutshell, I have a function that returns
my
> >array based on a SQL query and here's the code:
> >
> >-------------begin code-------------------
> >function getCourses($UID)
> >  {
> >  global $link;
> >  $result = mysql_query( "SELECT C.CourseName FROM tblcourses C, tblusers
U,
> >tblEnrollment E WHERE C.ID = E.CourseID AND E.UserID = U.ID AND U.ID =
> >$UID", $link );
> >  if ( ! $result )
> >   die ( "getRow fatal error: ".mysql_error() );
> >  return mysql_fetch_array( $result );
> >  }
> >------------end code ----------------
> >
> >I call this from a PHP page with the following code:
> >
> >------------begin code--------------
> >$myCourses = getCourses($session[id]);
> >foreach ($myCourses as $value)
> >  {
> >  print "<br>$value";
> >  }
> >------------end code---------------
> >
> >Now, when I test the SQL from my function directly on the database, it
> >returns just want I want it to return but it isn't working that way on my
> >PHP page. For results where there is a single entry, I am getting the
same
> >entry TWICE and for records with more than a single entry I am getting
ONLY
> >the FIRST entry TWICE.
> >
> >Now I know my SQL code is correct (I am testing it against a MySQL
database
> >using MySQL-Front) so I suspect I'm doing something stupid in my foreach
> >loop.
>
>
> I think your problem lies in a misunderstanding of the
> mysql_fetch_array() function. It doesn't return the entire result set
> in an array - just one record at a time. You can fix this in one of
> two ways:
>
> (1) Loop though the entire result set in your function:
>
>     function getCourses($UID)
>      {
>       global $link;
>
>       $ResultSet = array();
>
>       $result = mysql_query( "SELECT C.CourseName FROM tblcourses C,
tblusers U,
>        tblEnrollment E WHERE C.ID = E.CourseID AND E.UserID = U.ID AND
U.ID =
>        $UID", $link );
>
>       if ( ! $result )
>        die ( "getRow fatal error: ".mysql_error() );
>
>       while ($Row = mysql_fetch_array( $result ))
>       {
>        $ResultSet[] = $Row['C.CourseName'];
>       }
>
>       return $ResultSet;
>      }
>
>     ...
>
>     $myCourses = getCourses($session[id]);
>     foreach ($myCourses as $value)
>      {
>      print "<br>$value";
>      }
>
> or (2) set a flag in getCourses() so that the query is only executed
> once, otherwise returning a result line - something like:
>
>     function getCourses($UID)
>      global $link;
>      static $result = false;
>
>      if (!$result)
>       {
>         $result = mysql_query( "SELECT C.CourseName FROM tblcourses C,
> tblusers U,
>          tblEnrollment E WHERE C.ID = E.CourseID AND E.UserID = U.ID AND
U.ID =
>          $UID", $link );
>         if ( ! $result )
>          die ( "getRow fatal error: ".mysql_error() );
>       }
>      {
>      return mysql_fetch_array( $result );
>      }
>
>     ...
>
>     while ($Row = getCourses($session[id]) as $value)
>      {
>      print "<br>", $Row['C.CourseName'];
>      }
>
> (standard caveats about off-top-of-head, untested code apply)
>
> The reason you are getting the first record TWICE is becaouse of the
> default behaviour of the mysql_fetch_array() function. It returns
> both an associative array - ie, elements of the form <field-name> =>
> <value> - and a numerically indexed array (0, 1, 2, etc.). You can
> alter this behaviour by the second parameter of the function: see
>
> http://www.php.net/manual/en/function.mysql-fetch-array.php
>
> -steve
>
>
> >I'm hoping someone will spot my dumb mistake.  Thanks very much for any
help
> >at all on this.
> >
> >....Brad
> >
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --
> +------------------------------------------------------------------------+
> | Steve Edberg                                      [EMAIL PROTECTED] |
> | University of California, Davis                          (530)754-9127 |
> | Programming/Database/SysAdmin               http://pgfsun.ucdavis.edu/ |
> +------------------------------------------------------------------------+
> | The end to politics as usual:                                          |
> |                 The Monster Raving Loony Party (http://www.omrlp.com/) |
> +------------------------------------------------------------------------+


--- End Message ---
--- Begin Message ---
Has anyone got a working mcrypt.dll for php 4.2.1 and Windows 2000 Server?
--- End Message ---
--- Begin Message ---
what esle could i use?
"Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> You can only get it if the proxy provides you with this data.  Most don't,
> so this is not a reliable approach.
>
> -Rasmus
>
> On Sat, 29 Jun 2002, JJ Harrison wrote:
>
> > I want to check to see if people have voted yet for a poll.
> >
> > How can I get the ip of a user from both behind a proxy and the proxies
ip?
> >
> > is this simple?
> >
> > will i have trouble with firewalls etc?
> >
> >
> > --
> > JJ Harrison
> > [EMAIL PROTECTED]
> > www.tececo.com
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>


--- End Message ---
--- Begin Message ---
You need to assign each person a unique identifier of some sort.  ie.
assign them a login and password and verify that information by sending a
message to their email address.  Then only people with multiple email
addresses can spam your system with votes.

Beyond that it comes down to verifying each voter manually.  Get a phone
number and call each one up.  Even that is not quite foolproof.

Personal certificates might be an option here, but that is rather
cumbersome for everyone involved.

Basically there is no good solution for this problem.  Until everyone in
the world has a unique and non-spoofable, easily verifiable id number,
what you are trying to do is impossible.

Basically live with the fact that your voting system will be inaccurate
and spoofable.

-Rasmus

On Sun, 30 Jun 2002, JJ Harrison wrote:

> what esle could i use?
> "Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > You can only get it if the proxy provides you with this data.  Most don't,
> > so this is not a reliable approach.
> >
> > -Rasmus
> >
> > On Sat, 29 Jun 2002, JJ Harrison wrote:
> >
> > > I want to check to see if people have voted yet for a poll.
> > >
> > > How can I get the ip of a user from both behind a proxy and the proxies
> ip?
> > >
> > > is this simple?
> > >
> > > will i have trouble with firewalls etc?
> > >
> > >
> > > --
> > > JJ Harrison
> > > [EMAIL PROTECTED]
> > > www.tececo.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
>

--- End Message ---
--- Begin Message ---
John,

Try using the number_format function.

Bev

-----Original Message-----
From: John Wulff [mailto:[EMAIL PROTECTED]]
Sent: Saturday, June 29, 2002 3:10 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Limiting number of decimal places reported


How do I limit the number of decimal places returned in this query?

<?php

$result2 = mysql_query("SELECT sum(purchase_price) as total FROM assets
where order_number='$order_number'");

while(list($order_total) = mysql_fetch_row($result2))

{

print ("$order_total");

}

?>




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

--- End Message ---
--- Begin Message ---
on 29/06/02 2:53 AM, Kevin Stone ([EMAIL PROTECTED]) wrote:

> John I hate to critisize you since you are one of the most active members on
> this list.  But are these types of comments really useful?
> -Kevin

No, I'm with John on this one.  I'd say I type "no, JavaScript is
client-side, and PHP is server side" around 20 times a week to this list,
and that's only when I can be bothered.

Searching for pop-up in the archives would have solved the writers problem
in about 2 minutes.

For this group to maintain it's worth, we need to encourage users to do a
LITTLE research before asking obvious questions, and we need to discourage
people wasting our time with repetitive questions, or those who clearly
subscribe to the "but it's so easy to just send an email and wait to be
flamed" mentality.


Regards,

Justin French

--- End Message ---
--- Begin Message ---
on 29/06/02 3:20 AM, Tamas Arpad ([EMAIL PROTECTED]) wrote:

>> I was thinking if you use 90 character long filenames, assuming you only
>> use the letters of the alphabet and the digits then you would have 62^90
>> different filenames, which is roughly 2E161 (2 followed by 161 zeros),
>> which is quite a bit. Hopefully the numbers involved would make it
>> infeasible for an attacker to loop through all the permutations.
> 
> But what if the attacker just knows one file's name, for example index.php
> or something that's in the url in the browser. Then he/she can stole that
> file, read it, and gets other filenames because of includes/requires.
> With some work he/she can get all the files without any bruteforce
> filename guessing.

Well if a php file is parsed to the server, then they can't determine what
the orginal included fiels were at all, unless you're dumb enuff to do this:


<!-- include /inc/secret/passwords.inc -->
<?
include('/inc/secret/passwords.inc');
?>

:)

If you adopt some of the practices (I think) included earlier in this thread
by me, you could restrict browser access to your inc files by the use of
smart file naming, dedicated directories and .htaccess files, then this
should cover the basics of people grabbing your included files (with
passwords etc) via http (browser).

It doesn't cover people within the server (others on a shared server, etc)
though.


Justin French

--- End Message ---
--- Begin Message ---
I think there is also a directive in php.ini to ALWAYS include a certain
file at the top of each script, transparently.

Perhaps you could dynamically write to this file as needed, or dynamically
write to a MySQL table which is called/queried by this script.

This may or may not help, depending on your needs :)

Justin French


on 29/06/02 6:38 AM, Michael Sweeney ([EMAIL PROTECTED]) wrote:

> Depending on what data you need to have in these variables, you might be
> able to set them as environment variables through apache (that is, _if_
> you're running apache, _if_ you have access to the configuration file,
> _if_ mod_env is installed, etc). I'm guessing that wouldn't be a
> flexible enough alternative for you, but it might be worth considering.
> 
> ..michael..
> 
> On Fri, 2002-06-28 at 13:19, Jay Blanchard wrote:
>> [snip]
>> Perhaps something of this nature is already available and I don't know
>> about it, but in the scope of the current project I am working on it
>> would be beneficial to take the concept of superglobals and apply it to
>> sessions. That is, to be able to register a session-style variable in
>> which all instances of the script and/or server to access. I know it is
>> possible to use a database or write a file to keep track of such an
>> item, but it would be nice to have this feature built in to php.
>> [/snip]
>> 
>> I know what you mean. I have written a file that was included on every page
>> instance that had the session start function with all of the registered
>> session variables and included the database connections as well. Not as neat
>> as a supersession function you speak of, but workable.
>> 
>> Jay
>> 
>> 
>> 
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

--- End Message ---
--- Begin Message ---
PHPLib has session functions, and was essentially "what people used" before
PHP4.  It will of course require a fair bit of work to port your scripts
across.

Personally I'd change to another host :)


Justin French


on 29/06/02 2:17 PM, Cysec ([EMAIL PROTECTED]) wrote:

> I have already scripted a site using PHP 4 and was at the point of uploading
> it to my client's chosen server (decided to go third party) when I discover,
> their server is running PHP3, launch is in five days, and I have 40+ pages
> using PHP4's session handling (session_start() etc.).  This would be a total
> pain to change throughout the site, so I was wondering if anyone knew of a
> script of functions that emulate PHP4's session handling.  I would love to
> be able to just update the server, and would have if it were one I was
> administrating, however I can't.  Any help would be vastly appreciated.
> 
> 

--- End Message ---
--- Begin Message ---
Hi people,

Just a question, I'm building components for a customer who wants some 
interactivity within his site, but still wants to build the site himself. 
One thing that would be interesting would be Session management. Now, if I 
just tell him to make all his own pages with .php ext instead of .html, 
would did be enough if --enable-trans-sid is used (and php.ini is correctly 
configured)? It seems to work here, but I want to know if I forgot 
something important...

-- 
Kind regards,
Tim
--- End Message ---
--- Begin Message ---
enable-trans-sid appends a session id to URLs, but it works in conjunction
with php's session functions.  Simply compiling with --enable-trans-sid or
appending it to the URL yourself will not maintain session.

using functions like session_start() and the registering of session
variables ($_SESSION['something'] = "foo";) will establish/maintain a
session.

enable-trans-sid will only append a session ID to the URL for you if
needed... it's main use is for maintaining session across multiple pages
whilst not relying on cookies.

simply converting your files to .php and compiling with enable-trans-sid
will not give you sessions.


Justin French



on 30/06/02 5:47 AM, Tim Stoop ([EMAIL PROTECTED]) wrote:

> Hi people,
> 
> Just a question, I'm building components for a customer who wants some
> interactivity within his site, but still wants to build the site himself.
> One thing that would be interesting would be Session management. Now, if I
> just tell him to make all his own pages with .php ext instead of .html,
> would did be enough if --enable-trans-sid is used (and php.ini is correctly
> configured)? It seems to work here, but I want to know if I forgot
> something important...

--- End Message ---
--- Begin Message ---
Hi Justin,

Thx for the reply

Justin French wrote:

> using functions like session_start() and the registering of session
> variables ($_SESSION['something'] = "foo";) will establish/maintain a
> session.

Yes, I understand. Sessions need to be started. But once they have started, 
do I need to re-affirm the session on every page, or will it hold for a few 
pages, until the session-variables will be used again ...

> simply converting your files to .php and compiling with enable-trans-sid
> will not give you sessions.

... when I do this?

-- 
Kind regards,
Tim
--- End Message ---
--- Begin Message ---
on 30/06/02 9:04 PM, Tim Stoop ([EMAIL PROTECTED]) wrote:

> Yes, I understand. Sessions need to be started. But once they have started,
> do I need to re-affirm the session on every page, or will it hold for a few
> pages, until the session-variables will be used again ...

Well, you really need to check out a decent article/tutorial on sessions,
because it's a lot more in depth than can possible be explained here.  But
as a bare minimum, each page would need to call session_start() BEFORE the
<HTML> tag or any other content is sent to the browser.

You'd also need to register variables to the session (otherwise what's the
point?)

What is the session to be used for?


>> simply converting your files to .php and compiling with enable-trans-sid
>> will not give you sessions.
> 
> ... when I do this?

do what?


Justin French

--- End Message ---
--- Begin Message ---
On Sunday 30 June 2002 19:04, Tim Stoop wrote:
> Hi Justin,
>
> Thx for the reply
>
> Justin French wrote:
> > using functions like session_start() and the registering of session
> > variables ($_SESSION['something'] = "foo";) will establish/maintain a
> > session.
>
> Yes, I understand. Sessions need to be started. But once they have started,
> do I need to re-affirm the session on every page, or will it hold for a few
> pages, until the session-variables will be used again ...

There is a setting in php.ini, "session.auto_start", which enables php to 
automatically register a session. But as Justin suggests, you should refer to 
a decent article/book or manual for details.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
If you flaunt it, expect to have it trashed.
*/

--- End Message ---
--- Begin Message ---
Hi Justin,

Thx again for the answer.

Justin French wrote:

> Well, you really need to check out a decent article/tutorial on sessions,

Nah, I think I explain my question a little wierd and that's why you don't 
understand me... I've worked with sessions lots of times (although mostly 
in Java Servlets). Or something must be really crooked with my knowledge of 
standard sessions...

> because it's a lot more in depth than can possible be explained here.  But
> as a bare minimum, each page would need to call session_start() BEFORE the
> <HTML> tag or any other content is sent to the browser.

Ah yes, I forgot about that... I need to resume the session, of course. 
Would session.auto_start set to 1 work without these session_start()'s? The 
thing is, I need as less as possible of a hassle to have the sessions 
work... Read on for an explanation.

> You'd also need to register variables to the session (otherwise what's the
> point?)
> 
> What is the session to be used for?

Well... For a shopping-cart actually :)

But not the "standard" kind. I'm building a set of components that a 
webdesigner can use easily, without actually understanding how the code 
works. The webdesigner (my customer) wants to build a site where his 
customers can browse to some products and put them in their shopping-cart 
with simple code. Something like:

<HTML>
<HEAD>
  bla bla..
</HEAD>
<BODY>
<H1>Buy this product!</H1>
<P>bla bla</P>
<?php 
  include("functions.php");
  makeBuyButton("black shoes, size 34");
?>
</BODY>
</HTML>

I do the work with the variables and all, he only needs to make sure 
everything looks fine. I used to do this with Cookies, but they're evil :) 
Besides, a session-solution a much prettier :) I want to know if the 
session is maintained if he makes use of the components and has all his 
files extend on .php, when I have --enable-trans-sid on and (as noted in 
this mail) session.auto_start.

I think this would work? I made a test-site locally, but I need to know the 
exact options that make this work, so I can inform the provider what to 
change (very helpful chaps over there, just don't know sh*t about PHP).

-- 
Kind regards,
Tim
--- End Message ---
--- Begin Message ---
I have a switch in a script I'm working on.  I need to have case 1 and 2 
both to to case 3, but without case 1 going through case 2.  Is this 
possible?

--- End Message ---
--- Begin Message ---
At 5:18 AM -0400 6/30/02, Leif K-Brooks wrote:
>I have a switch in a script I'm working on.  I need to have case 1 
>and 2 both to to case 3, but without case 1 going through case 2. 
>Is this possible?


No, but you can do it this way:

switch ($foo) {

    case 1:
       ...
       do_something();
       break;

    case 2:
       ...
       do_something();
       break;

    case 3:
       do_something();
       break;

}

function do_something() {

    # this is the stuff that you want to do that is common to your
    # cases 1, 2 and 3

}

This accomplishes the same thing.

-steve


-- 
+------------------------------------------------------------------------+
| Steve Edberg                                      [EMAIL PROTECTED] |
| University of California, Davis                          (530)754-9127 |
| Programming/Database/SysAdmin               http://pgfsun.ucdavis.edu/ |
+------------------------------------------------------------------------+
| The end to politics as usual:                                          |
|                 The Monster Raving Loony Party (http://www.omrlp.com/) |
+------------------------------------------------------------------------+
--- End Message ---
--- Begin Message ---
Hi
One way to achieve the same effect:

fallthru = 0;
switch($whatever){
         case "1":
                 do something1;
                 $fallthru = 1;
         case "2":
                 if(!$fallthrough){
                         do something2;
                 }
         case "3"
                 do something3;
         break;
}

Tom


At 05:18 AM 30/06/2002 -0400, Leif K-Brooks wrote:
>I have a switch in a script I'm working on.  I need to have case 1 and 2 
>both to to case 3, but without case 1 going through case 2.  Is this possible?
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message ---
Hi all.
 
I know it’s Sunday morning and that I’m NOT getting many responses right
now ;-)
 
I connected to the net, opened my browser, pointed it towards an e-mail
script I’ve installed this afternoon in my site (SquirrelMail) qnd got
into the INBOX… once there, I opened my MS Outlook and received 21
messages regarding PHP mailing list stuff, but all these had no FROM,
SUBJECT, TO or CC……… I mean, they had body content but no headers to
show… ¿¿¿???
 
 <mailto:[EMAIL PROTECTED]> Cesar Aracena
CE / MCSE+I
Neuquen, Argentina
+54.299.6356688
+54.299.4466621
 
--- End Message ---
--- Begin Message ---
Can you post the code on here?
There must be some headers somewhere because the mail has been sent to
you -> to header.
Have you clicked on the email in Outlook and looked at the headers / message
source?

"César aracena" <[EMAIL PROTECTED]> wrote in message
002a01c22019$21a0c210$dfc405c8@gateway">news:002a01c22019$21a0c210$dfc405c8@gateway...
Hi all.

I know it's Sunday morning and that I'm NOT getting many responses right
now ;-)

I connected to the net, opened my browser, pointed it towards an e-mail
script I've installed this afternoon in my site (SquirrelMail) qnd got
into the INBOX. once there, I opened my MS Outlook and received 21
messages regarding PHP mailing list stuff, but all these had no FROM,
SUBJECT, TO or CC... I mean, they had body content but no headers to
show. ¿¿¿???

 <mailto:[EMAIL PROTECTED]> Cesar Aracena
CE / MCSE+I
Neuquen, Argentina
+54.299.6356688
+54.299.4466621






--- End Message ---
--- Begin Message ---
I realise its a longshot but is it possible to use PHP (or any other
web-based languages) to combine multiple ZIP files into a single ZIP file?
and any scripts i can download to do it.

Any help with this is most appreciated. ;-)


--- End Message ---
--- Begin Message ---
On Sunday 30 June 2002 15:32, Tony Harrison wrote:
> I realise its a longshot but is it possible to use PHP (or any other
> web-based languages) to combine multiple ZIP files into a single ZIP file?
> and any scripts i can download to do it.
>
> Any help with this is most appreciated. ;-)

If you have a command-line zip program on your system then just use exec() (or 
friends) to run it.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
... I see TOILET SEATS ...
*/

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

i discovered bug in sessions:

when using unset($_SESSION[...]) insted session_unregister(...) and
before calling read _$SESSION[...] variable WILL NOT unset.

please try these examples and see result.

here is method how to produce this bug (you must have cookies enabled):
1. run script
2. reload page (you should see 2 $_SESSION arrays with the same value)
3. click on unset link
4. now you should see first array filled with test value and second
should be empty - that's OK - but variable test should be deleted from
session
5. reload page
6. here is BUG: i unset session variable test so i shouldn't exists,
but exists.
---

7. comment line marked #fatal

and go to repeat process from begining
on step 6. both arrays will be empty!!!!

----------------cut here----------------------------------------------
<?php
session_start();
echo '<pre>';

print_r($_SESSION);

if (isset($_GET['submit'])) {
        $test = $_SESSION['test'];                      # fatal
        unset($_SESSION['test']);
} else {
        $_SESSION['test'] = 'this is test';
}
echo '<a href="'.$_SERVER['PHP_SELF'].'?submit=yes">unset</a><br>';
print_r($_SESSION);
echo '</pre>';
?>
----------------cut here----------------------------------------------


replace        unset($_SESSION['test']); with
session_unregister('test'); and repeat process - here will be
everything OK.

http://www.php.net/manual/en/ref.session.php (see Example 3.)

Tested on PHP 4.2.1 (win, Debian).

Epilogue: using unset at $_SESSION array is NOT safe.

Regards,
Michal Dvoracek                          [EMAIL PROTECTED]
Capitol Internet Publisher, Korunovacni 6, 170 00 Prague 7, Czech Republic
tel.: ++420 2 3337 1117, fax:  ++420 2 3337 1112

--- End Message ---
--- Begin Message ---
Hi,

I am trying to write a program that is very modular in nature & one of the
features I need the user to be able to do is install/uninstall or
enable/disable the module though the interface.

I have though of 2 ways this could be done, either when the module is
installed it adds additional lines to an include file, which means the next
time the page is loaded the new module will also be included.  Alternatively
I though of writing my own config files and using fopen etc to read in the
values and store them as appopriate.

If I was writing this as a compiled program in C / Java, I would definately
use the fopen method as the operation only needs to be done either a program
start or when a new module is added.  However with PHP the operation would
need to be done on each page request.

As far as I can tell both methods ultimately come down to opening a file and
reading it in, but I would think that the built in include directive would
be less of a performance risk that writing my own handler.  The problem is
by using include files I run the risk of if my script/server crashes
half-way though a write or the user makes an error when editing the page
directly it would possibly bring down the whole app, where as if I read the
values in via my own file & methods I can ensure that the values and syntax
are valid before acting upon what is read in.

Therefore if my assumptions are correct I am caught between either possibily
having a faster program but is possibly not a resiliant to error, or a
slower program that is more resiliant and can exit nicely on error.

Any thoughs that people have on this would be appriciated.

Regards

Lee

--- End Message ---
--- Begin Message ---
On Sunday 30 June 2002 03:03, Mike Tuller wrote:
> To let everyone know, I did apologize to Mr. Wong. I misunderstood what he
> was trying to ask me. I took it as he was saying "It's easy, what is "your"
> problem" rather than "What "is" your problem" .

Thanks. But no need to call me "Mr" though :)

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Yevtushenko has... an ego that can crack crystal at a distance of twenty feet.
                -- John Cheever
*/

--- End Message ---
--- Begin Message ---
On Sunday 30 June 2002 03:09, Nookie wrote:
> Hi,
>
> I want to write function which change variable in ie. config.php file ...
> Here is code:
>
> <?
>
> include "config.php";
>
> $file = fopen("config.php", "w+");
>
> $content = fread($file, filesize("config.php"));
>
> $content = str_replace("\$option['test'] = \"" . $option['test'] . "\";",
> "\$option['test'] = \"po tescie\";", $content);
>
> fwrite($file, $content);
>
> ?>
>
> and config.php:
>
> <?
>
> $option['test'] = "test";
>
> ?>
>
> and it's doesn't work :( ... when I run script, it clear config.php and
> nothing else ... where is my fault?

What does $content contain?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
I'm still waiting for the advent of the computer science groupie.
*/

--- End Message ---
--- Begin Message ---
Maybe I am just doing it incorrectly but I am unable
to get anything displayed with imageellipse in
gdlib2.0.

Can anyone give me a simple php script to test it
with? I am using php with Sablotron.

Thank you.
-- 
Bill
Amsterdam, NL
--- End Message ---

Reply via email to