OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 16 Jun 2004 08:12:30 -0000 Issue 2824

php-general-digest-helplists.php.net
Date: Wed Jun 16 2004 - 03:12:30 CDT


php-general Digest 16 Jun 2004 08:12:30 -0000 Issue 2824

Topics (messages 188350 through 188376):

Excel files with multiple sheets
        188350 by: Robert Sossomon
        188351 by: Jay Blanchard
        188357 by: Torsten Roehr

mail
        188352 by: Chris W
        188355 by: Chris W

Namespace issues
        188353 by: Shaunak Kashyap
        188358 by: Justin Patrin

Re: Text message
        188354 by: Lester Caine
        188373 by: Ulrik S. Kofod

Re: Unit Testing
        188356 by: Justin Patrin
        188376 by: Trevor Nesbit

Re: [SOLVED] Namespace issues
        188359 by: Shaunak Kashyap

Chat-name forms and Suffixes with Validation...
        188360 by: Ryan Munevar
        188366 by: Curt Zirzow

Just Testing
        188361 by: Michael Lauzon
        188362 by: Greg Donald
        188364 by: Curt Zirzow
        188375 by: Kevin Clark

Active windows
        188363 by: Info.Best-IT
        188365 by: Curt Zirzow

ADOdb db abstraction library moved to sourceforge
        188367 by: John Lim

Losing Sessions
        188368 by: Paul Liebrand
        188369 by: Curt Zirzow
        188370 by: Paul Liebrand
        188371 by: Curt Zirzow

Re: Regarding variable reference
        188372 by: Ulrik S. Kofod

Re: array_rand() not random
        188374 by: Kim Steinhaug

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


I have been looking but have not found yet of a way to generate an excel
file with multiple pages using a PHP page. I was hoping someone here
might have hit on a multiple page document. I can do a single file, but
was looking for something a little more powerful before I try to create
my own. No sense in re-inventing the wheel...

TIA!

Robert

attached mail follows:


[snip]
I have been looking but have not found yet of a way to generate an excel
file with multiple pages using a PHP page. I was hoping someone here
might have hit on a multiple page document. I can do a single file, but
was looking for something a little more powerful before I try to create
my own. No sense in re-inventing the wheel...
[/snip]

There is PHP class called writeExcel (original was PERL)
http://search.cpan.org/src/JMCNAMARA/Spreadsheet-WriteExcel-0.37/WriteEx
cel/doc/WriteExcel.html

attached mail follows:


"Robert Sossomon" <robertgcnorris.com> wrote in message
news:002b01c45313$65439b30$6601010aroot2...
> I have been looking but have not found yet of a way to generate an excel
> file with multiple pages using a PHP page. I was hoping someone here
> might have hit on a multiple page document. I can do a single file, but
> was looking for something a little more powerful before I try to create
> my own. No sense in re-inventing the wheel...

Hi Robert,

have you looked at PEAR's Spreadsheet_Excel_Writer?:
http://pear.php.net/package/Spreadsheet_Excel_Writer

Regards, Torsten Roehr

attached mail follows:


I have upgraded from SUSE 9.0 to 9.1 and now having problems with the
mail function.

First I was getting an unknown function mail. An suse update fixed
that. Now the mail function seems to execute fine but no message ever
gets to where I sent it. I looked at the mail log from the postfix
program and it seems to be saying that there were no recipients, but the
exact same code works fine on another machine with suse 9.0 and the same
config file for postfix. Anyone have any ideas? Just in case, here are
the log entries from postfix....

Jun 15 14:58:09 WebServer postfix/pickup[2220]: C6EDA23A2F: uid=30
from=<wwwrun>
Jun 15 14:58:09 WebServer postfix/cleanup[2617]: C6EDA23A2F:
message-id=<20040615195809.C6EDA23A2Faopro.com>
Jun 15 14:58:09 WebServer postfix/cleanup[2617]: C6EDA23A2F:
to=<unknown>, relay=none, delay=0, status=bounced (No recipients specified)

--
Chris W

Bring Back the HP 15C
http://hp15c.org

Not getting the gifts you want? The Wish Zone can help.
http://thewishzone.com

attached mail follows:


php-list-replieslistmail.innovate.net wrote:

> have you debugged your php code to confirm that a recipient is really
> getting put on the message? e.g., print out the "to:" line, or better
> yet, hard-code a recipient in the code. based on what you find,
> you'll have a better sense as to whether the issue is on the mta side
> or your php (and i assume database) code side.
>
the only change I made was move the code from a suse 9.0 machine to an
suse 9.1 machine at a different location. The code I am uisng to test
is very simple

<?php
$message = "This is a Test Message ";
mail('1qazse4cox.net', "test message", $message);
?>

--
Chris W

Bring Back the HP 15C
http://hp15c.org

Not getting the gifts you want? The Wish Zone can help.
http://thewishzone.com

attached mail follows:


Hi,

Facts:

1. I have the following four scripts: a.php, b.php, c.php and d.php
2. a.php defines a function named foo.
3. b.php includes c.php
4. c.php defines a function named foo

Case I: d.php looks like this:

<code>
include "b.php";
include "a.php";
</code>

This causes a fatal error that says that foo cannot be redeclared.

Case II: I change d.php to look like this:

<code>
include "a.php";
include "b.php";
</code>

This does NOT cause the same fatal error. When I called foo from d.php, it
called the foo defined in a.php

Can anyone explain why a fatal error wasnt caused in Case II? I am using PHP
version 4.2.3

Thank you,

Shaunak Kashyap

attached mail follows:


Shaunak Kashyap wrote:

> Hi,
>
> Facts:
>
> 1. I have the following four scripts: a.php, b.php, c.php and d.php
> 2. a.php defines a function named foo.
> 3. b.php includes c.php
> 4. c.php defines a function named foo
>
>
> Case I: d.php looks like this:
>
> <code>
> include "b.php";
> include "a.php";
> </code>
>
> This causes a fatal error that says that foo cannot be redeclared.
>
> Case II: I change d.php to look like this:
>
> <code>
> include "a.php";
> include "b.php";
> </code>
>
> This does NOT cause the same fatal error. When I called foo from d.php, it
> called the foo defined in a.php
>
>
> Can anyone explain why a fatal error wasnt caused in Case II? I am using PHP
> version 4.2.3
>
> Thank you,
>
> Shaunak Kashyap

Perhaps you have a function_exists() (or similar) call wrapping the
declaration of foo() in c.php?

If you're using this same function in multiple files and it's the same
funciton, you ought to put it in its own file and require_once() the
file in the places where you need it. That way, you don't get this
problem. You could also wrap all of the declarations in
funciton_exists() calls.

--
paperCrane <Justin Patrin>

attached mail follows:


R'Twick Niceorgaw wrote:

> Is this some kind of virus? anybody else receiving it?
>
> I have received 3 mails from this address through the list today all with a .bmp
> attachment
>
> It has passed clam av + fprot on linux as well as norton on windows but still
> want to double check before opening it.
>
> - R'twick
> Quoting Hitcho <hitchophp.net>:

hitcho has had his email address harvested, and it is now being used to
propagate virus payloads. He is not the only one, but since he has a
valid php account it is not being kicked out when posted to the php lists.

It's payload has probably already been wiped, but in any case, messages
like this just go straight to trash. We could do with a moderator on
these lists to clear some of them out :)

--
Lester Caine
-----------------------------
L.S.Caine Electronic Services

attached mail follows:


Lester Caine sagde:
> R'Twick Niceorgaw wrote:
>
>> Is this some kind of virus? anybody else receiving it?
>>
>> I have received 3 mails from this address through the list today all with a .bmp
>> attachment
>>
>> It has passed clam av + fprot on linux as well as norton on windows but still
>> want to double check before opening it.
>>
>> - R'twick
>> Quoting Hitcho <hitchophp.net>:
>
> hitcho has had his email address harvested, and it is now being used to
> propagate virus payloads. He is not the only one, but since he has a
> valid php account it is not being kicked out when posted to the php lists.
>
> It's payload has probably already been wiped, but in any case, messages
> like this just go straight to trash. We could do with a moderator on
> these lists to clear some of them out :)
>

Isn't it possible to reject all mails send to the list with attachments all
together, with a bounce message saying something like that mails to the list should
be plain text without attachments ?

It would also be nice to have bounce messages removed; it's annoying to receive X
messages about mail accounts on the list that doesn’t exist anymore.

/usk
ps. don't kill me it's just a suggeation.

attached mail follows:


Rick Fletcher wrote:

> Has anyone done any PHP unit testing? I've been looking around for a unit
> testing library to try out. Below are the ones I've found so far:
>
> SimpleTest: http://www.lastcraft.com/simple_test.php
> PHPUnit (dead?): http://phpunit.sourceforge.net/
> Pear PHPUnit: http://pear.php.net/package/PHPUnit
> Generic PHP Framework (dead?): http://gpfr.sourceforge.net/
>
> SimpleTest looks the most complete and the most active, so that's where I'm
> leaning. Anyone have any experience with any of these libraries, or have any
> comments on PHP Unit testing in general?
>
> Thanks.
>
> Rick

PHPUnit in PEAR at least is still in development. PHPUnit2 is really the
one that's still being worked on, though, and it's PHP5 only...

--
paperCrane <Justin Patrin>

attached mail follows:


Hi

I'm interested in locating something straight forward to teach to our
programming students...

Am appreciating the discussion so far...

Trevor Nesbit
MBS BSc BCom CA PGDipBusAdmin
Degree Leader for Bachelor of ICT
Programme Leader for Graduate Diploma in eCommerce
School of Computing - www.cpit.ac.nz/computing
School of Business
Christchurch Polytechnic Institute of Technology
>>> "Torsten Roehr" <roehrzilleon.com> 06/16/04 07:37 AM >>>
"Rick Fletcher" <ricksnocap.com> wrote in message
news:200406151904.i5FJ4B8h020570d7.sfo.snocap.com...
> Has anyone done any PHP unit testing? I've been looking around for a
unit
> testing library to try out. Below are the ones I've found so far:
>
> SimpleTest: http://www.lastcraft.com/simple_test.php
> PHPUnit (dead?): http://phpunit.sourceforge.net/
> Pear PHPUnit: http://pear.php.net/package/PHPUnit
> Generic PHP Framework (dead?): http://gpfr.sourceforge.net/
>
> SimpleTest looks the most complete and the most active, so that's
where
I'm
> leaning. Anyone have any experience with any of these libraries, or
have
any
> comments on PHP Unit testing in general?

Don't have any experience myself but here's a nice article by Harry
about
SimpleTest:
http://www.sitepoint.com/blog-post-view.php?id=175190

Hope it helps. Regards,
Torsten Roehr

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

attached mail follows:


Yes, thank you Justin. I DID have a function exists which I somehow did not
notice earlier.

Shaunak

> -----Original Message-----
> From: Justin Patrin [mailto:papercranereversefold.com]
> Sent: Tuesday, June 15, 2004 4:49 PM
> To: php-generallists.php.net
> Subject: Re: [PHP] Namespace issues
>
>
> Shaunak Kashyap wrote:
>
> > Hi,
> >
> > Facts:
> >
> > 1. I have the following four scripts: a.php, b.php, c.php and d.php
> > 2. a.php defines a function named foo.
> > 3. b.php includes c.php
> > 4. c.php defines a function named foo
> >
> >
> > Case I: d.php looks like this:
> >
> > <code>
> > include "b.php";
> > include "a.php";
> > </code>
> >
> > This causes a fatal error that says that foo cannot be redeclared.
> >
> > Case II: I change d.php to look like this:
> >
> > <code>
> > include "a.php";
> > include "b.php";
> > </code>
> >
> > This does NOT cause the same fatal error. When I called foo
> from d.php, it
> > called the foo defined in a.php
> >
> >
> > Can anyone explain why a fatal error wasnt caused in Case II? I
> am using PHP
> > version 4.2.3
> >
> > Thank you,
> >
> > Shaunak Kashyap
>
> Perhaps you have a function_exists() (or similar) call wrapping the
> declaration of foo() in c.php?
>
> If you're using this same function in multiple files and it's the same
> funciton, you ought to put it in its own file and require_once() the
> file in the places where you need it. That way, you don't get this
> problem. You could also wrap all of the declarations in
> funciton_exists() calls.
>
> --
> paperCrane <Justin Patrin>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


Hi Everyone,

        I'm making a form that takes the chat name user enters and combines it
with the chat suffix.

         Does anyone have a list of all the available chat clients out there?
So far I have, AIM, .mac, iChat.
        
        What's the easiest way to combine them with the actual name?
JoeTreeman6.mac for example.

        But how do I do it if it's something like SarahPoley69 on AIM? Does
it even have a suffix?
        
        What about checking to see if they are on line? Not signed into the
site but actually on line yaking away in cyberspace somewhere.

        And is it possible to verify a chat-names authenticity? Like does it
really exist? Or if it's one of those sex bots that bombards the AIM
chat rooms with 18/f/Web Cam crap?

        Thanks in advance.

                                                                                        Sincerely,
                                                                                                Ryan Munevar

attached mail follows:


* Thus wrote Ryan Munevar (munevarrdslextreme.com):
> Hi Everyone,
>
> I'm making a form that takes the chat name user enters and combines
> it with the chat suffix.

I'm unclear on what you're asking here.

> Does anyone have a list of all the available chat clients out
> there? So far I have, AIM, .mac, iChat.

There are virtually endless numbers of chat clients, not to mention
protocols. It is up to you wich ones to support:

  To name a couple:
    jabber (probably the best to support)
    ICQ
    Yahoo!
    zircu

>
> What's the easiest way to combine them with the actual name?
> JoeTreeman6.mac for example.

again unclear.

>
> But how do I do it if it's something like SarahPoley69 on AIM? Does
> it even have a suffix?
>

remains unlear.

> What about checking to see if they are on line? Not signed into the
> site but actually on line yaking away in cyberspace somewhere.
 
Depends on the protocol

> And is it possible to verify a chat-names authenticity? Like does
> it really exist? Or if it's one of those sex bots that bombards the AIM
> chat rooms with 18/f/Web Cam crap?

Depends on protocol. but I might be rather interested in that
18f/cam stuff ;)

HIWTH

Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!

attached mail follows:


I am just testing, so that I can create a filter.

--
Michael Lauzon, Founder
The Quill Society
http://www.quillsociety.org/
mlauzonquillsociety.org

attached mail follows:


On Tue, 15 Jun 2004 19:21:39 -0400, Michael Lauzon <mlauzongmail.com> wrote:
> I am just testing, so that I can create a filter.

Or a label rather?

--
Greg Donald
http://destiney.com/

attached mail follows:


* Thus wrote Michael Lauzon (mlauzongmail.com):
> I am just testing, so that I can create a filter.

btw, you're going about it wrong.

Filters will just contribute spaming to the list.

Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!

attached mail follows:


Um how so?

On Wed, 16 Jun 2004 04:18:27 +0000, Curt Zirzow
<php-generalzirzow.dyndns.org> wrote:
>
> * Thus wrote Michael Lauzon (mlauzongmail.com):
> > I am just testing, so that I can create a filter.
>
> btw, you're going about it wrong.
>
> Filters will just contribute spaming to the list.
>
> Curt
> --

attached mail follows:


I am trying to get my website to refresh when the window becomes active.

This is needed so when a user downloads a report and the PDF is displayed,
there is now a new state in the previously active window. However, the page
needs to refresh to regenerate the new page. Any ideas on how to do this?
Can one send header information to a separate window, or discern between
active and non active windows?

I know this is a stretch but I thought Iąd ask....

/T

attached mail follows:


* Thus wrote InfoBest-IT (infobest-it.biz):
> I am trying to get my website to refresh when the window becomes active.
>
> This is needed so when a user downloads a report and the PDF is displayed,
> there is now a new state in the previously active window. However, the page
> needs to refresh to regenerate the new page. Any ideas on how to do this?
> Can one send header information to a separate window, or discern between
> active and non active windows?
>
> I know this is a stretch but I thought Iąd ask....

yes it is a stretch.

Determining what a client is going to do on focus is practically
impossible. Even with javascript unless you're in a closed
environment.

Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!

attached mail follows:


Hello,

ADOdb is a popular database abstraction library for PHP. It supports
a very large number of databases, including MySQL, PostgreSQL,
Firebird, Interbase, SQLite, Oracle, Frontbase, DB2, SAP DB, Sybase,
Informix, Netezza, Access, VFP, MS SQL, LDAP, ODBTP, ODBC, etc.

Due to system outages at the current site, the home page of ADOdb
has moved to sourceforge.

Kindly update your links to

http://adodb.sourceforge.net/

Given the move to sourceforge, we have decided to take advantage
of its services and we have created 2 new mailing lists:

adodb-news: low volume moderated list for important news
http://lists.sourceforge.net/lists/listinfo/adodb-news

adodb-general: for general postings
http://lists.sourceforge.net/lists/listinfo/adodb-general

Bugs should still be reported at the existing forums at
http://phplens.com/lens/lensforum/topics.php?id=4

Thank you.

John Lim

attached mail follows:


I am hosting a web site on tierranet and throughout the day sessions get
lost. If I take the exact same code and run it on my Windows machine, I can
run it for a week straight without any problems. I have not been able to
figure out the problem and was wondering if anyone can provide any
assistance or feedback.

At the top of most of my pages I have the following piece of code:

if (!session_is_registered("valid_user")) {
    header ("location: logon.php");
}

Obviously when the session gets lost, this piece of code redirects the user
to the logon page. I have looked through my code and cannot figure it out (i
do not believe it is a code problem).

The server is running PHP 4.3.4

Please -- someone help!

Paul

Version: 6.0.705 / Virus Database: 461 - Release Date: 6/12/2004

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.705 / Virus Database: 461 - Release Date: 6/12/2004

attached mail follows:


* Thus wrote Paul Liebrand (pliebrandimaxa.com):
> I am hosting a web site on tierranet and throughout the day sessions get
> lost. If I take the exact same code and run it on my Windows machine, I can
> run it for a week straight without any problems. I have not been able to
> figure out the problem and was wondering if anyone can provide any
> assistance or feedback.
>
> At the top of most of my pages I have the following piece of code:
>
> if (!session_is_registered("valid_user")) {
> header ("location: logon.php");
> }

using sesion_is_registered() depends on a couple things:
  1. register_globals is on
  2. you are using a super old method of using sessions.

1. if you're relying on register_global to be on that is usually
   frowned upon. The best method to do sessions is usually with
   $_SESSION, if you're not using an archaic versionn of php.

     // start session
     session_start()
     
     // set a session var
     $_SESSION['var'] = 'a value';

     // check session existence
     if (isset($_SESSION['var']) ) ...

     // unset session var
     unset($_SESSION['var']);

2. read http://php.net/session a couple of time's to verify correct
   usage. and *do* take not of the "warning" sections.

Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!

attached mail follows:


Curt,

Thanks for the reply.

I am going to go ahead and change all my session variables to use the
methods you described. Because I am using the session_register method, could
this be the cause of my problem? That it works 90% of the time, but a couple
times throughout the day the sessions just get lost?

Thanks,

Paul

"Curt Zirzow" <php-generalzirzow.dyndns.org> wrote in message
news:20040616045707.GW80292bagend.shire...
> * Thus wrote Paul Liebrand (pliebrandimaxa.com):
> > I am hosting a web site on tierranet and throughout the day sessions get
> > lost. If I take the exact same code and run it on my Windows machine, I
can
> > run it for a week straight without any problems. I have not been able to
> > figure out the problem and was wondering if anyone can provide any
> > assistance or feedback.
> >
> > At the top of most of my pages I have the following piece of code:
> >
> > if (!session_is_registered("valid_user")) {
> > header ("location: logon.php");
> > }
>
> using sesion_is_registered() depends on a couple things:
> 1. register_globals is on
> 2. you are using a super old method of using sessions.
>
> 1. if you're relying on register_global to be on that is usually
> frowned upon. The best method to do sessions is usually with
> $_SESSION, if you're not using an archaic versionn of php.
>
> // start session
> session_start()
>
> // set a session var
> $_SESSION['var'] = 'a value';
>
> // check session existence
> if (isset($_SESSION['var']) ) ...
>
> // unset session var
> unset($_SESSION['var']);
>
>
> 2. read http://php.net/session a couple of time's to verify correct
> usage. and *do* take not of the "warning" sections.
>
>
>
> Curt
> --
> First, let me assure you that this is not one of those shady pyramid
schemes
> you've been hearing about. No, sir. Our model is the trapezoid!

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.705 / Virus Database: 461 - Release Date: 6/12/2004

attached mail follows:


* Thus wrote Paul Liebrand (pliebrandimaxa.com):
> Curt,
>
> Thanks for the reply.
>
> I am going to go ahead and change all my session variables to use the
> methods you described. Because I am using the session_register method, could
> this be the cause of my problem? That it works 90% of the time, but a couple
> times throughout the day the sessions just get lost?

hmm.. i I guess I didn't really cover why the session's would get
lost. From my experience they really dont get lost, they just don't
get set properly. And using a session_register() with $_SESSION or
$HTTP_SESION_VARS along withh register_globals being on usually
complicates the whole process.

Assuming you're using cookies, the only way they usually get lost
is when the user rejects a cookie after accepting cookies for a
couple pages, which is usually a rare case unless your me :)

As I noted in my previous message i would also add, after
re-evalulating the session docs, is to also pay attention to the
'cautions' as well. They usually clearify why session's aren't
working they way they should.
 

Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!

attached mail follows:


Justin Patrin sagde:
> Ulrik S. Kofod wrote:
>
> Why are you using eval? Eval is slow and is a hack... Just do:
> $y = $$x;
>
>> if(isset($y))
>> {
>> echo "<p>$x:$y</p>";
>> }
>> }
>

True ! I just tested it with both eval and $$, and $$ seems to be about 3 to 4 times
faster than eval BUT if you are processing less than 10000 variables then there is
no noticeable difference.

Sorry I suggested eval!

but I think it is easier to read the program when using eval as it is more eye
catching than just an extra $ that is easily missed.

attached mail follows:


Well,

I must admit Im gotten abit to familiar with the use of MySQL lately,
though it might be abit overkill - but what the heck. The database is
there to be used and we shouldnt worry to much. For those really
worrying there are several file based "sql" alternatives out there.

Ok, I would use and update statement against the SQL database,
soething like :

update my_stats_table set counter=counter+1 where id=1

All you need is to fire this query on every page, well, you might have
different counters for different pages I just used the ID=1 as an
example, it might aswell be "page='frontpage'"

If you need a more dynamic sollution, meaning you have contents that
you want logged that change from time to time - and you do not
want to prepare the database all the time you could do it like this,
remember
I use a DB extraction layer function named query, so whenever I write
query I really mean mysql_query... Assuming your counting banners

query("update my_stats_table set counter=counter+1 where id=" .
md5($bannername));
if(!mysql_affected_rows)
    query("inserted my_stats_table (id, counter) VALUES ('" .
md5($bannername) . "',1)");

You see the logic with the mysql_affected_rows. Now your still stuck with
doing
some nifty stats generating from the data you have in your table - but now
you have
numbers in the database and you have several options.

One that suddenly comes to mind, is always showing the one with the smallest
impressions.

$result = query("select * from my_stats_table where order by counter limit
1");

You would here need to add more information, probably might aswell include
the entire
banner in the database.

Well, BTW, hope this helps you.
--
--
Kim Steinhaug
----------------------------------------------------------------------
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
----------------------------------------------------------------------
www.steinhaug.com - www.easywebshop.no - www.webkitpro.com
----------------------------------------------------------------------

on Sun, 13 Jun 2004 01:15:20AM +0200, Kim Steinhaug insinuated:
> Hmm... Ive been having same problems with mysql and picking random
> numbers, I ended up having to program a rather more sofisticated
> system to eliminate the stats you were referring to.
>
> You could, not that it will be any better, try another approach :
>
> Something like :
>
> $count = count($your_data_array);
> $random = rand(0, $count);
> echo $your_data_array[$random];
>
> PHP is maby using the same random function for both the array_rand and
> rand for all I know but its worth a go.

yeah, since they use the same thing i'm not sure it'd be worth the
effort.

> The harder way would be to include an internal counter for your
> elements you want to be randomized, so that when an item is selected
> you count it. Then the next time you calculate the random element
> you take the accual hits into meassure. There are like a 1000 ways
> to do this so use your imagination.

that would be cool. but how do you maintain the value of a counter
from reload to reload? would i have to open an external file, read
its variable, increment it, write to it, and close it every time? or
is there a way to do that in the code of a single php page?

thanks again,

</nori>

--
    .~. nori sccs.swarthmore.edu
    /V\ http://www.sccs.swarthmore.edu/~nori
   // \\ maenad.net
  /( )\ www.maenad.net/jnl
   ^`~'^

++ Sponsor me as I run my SECOND marathon for AIDS: ++
++ http://www.aidsmarathon.com/participant.asp?runner=DC-2844 ++