Re: [PHP] Loop, array, life....

2002-04-03 Thread Christopher William Wesley

You only want to retrieve the news from your table once.
So, pull pull this code:
>  $container[] = $message;
>  while (list($news, $date) = mysql_fetch_row($newsfetch)) {
>  $container[] = '' . $news . '';
>  $container[] = '';
>   }
>   $container[] = '';

outside of (before) this loop:

> while ($data = mysql_fetch_row($emailfetch)) {

~Chris /"\
   \ / Microsoft Security Specialist:
X  The moron in Oxymoron.
   / \ http://www.thebackrow.net

On Wed, 3 Apr 2002, Gerard Samuel wrote:

> Ok, this one is breaking my back all day.
> First some sudo-code ->
>
> fuction email_to_user() {
>  $sql = 'select distinct(email) from user';
>  $emailfetch = mysql_query($sql);
>
>  $sql = 'select news, date from news order by sid desc limit 10';
>  $newsfetch = mysql_query($sql);
>
>  while ($data = mysql_fetch_row($emailfetch)) {
>  $container = array();
>  $container[] = '';
>
>  $message = 'Have a nice day';
>  $container[] = $message;
> // PROBLEM IN THIS WHILE LOOP MAYBE //
>  while (list($news, $date) = mysql_fetch_row($newsfetch)) {
>  $container[] = '' . $news . '';
>  $container[] = '';
>  }
>  $container[] = '';
>  $message = '';
>  foreach($container as $foo) {
>  $message .= $foo;
>  }
>  mail(Send mail to $data[0]);
>  unset($container);
>  }
> }
>
> Basically it grabs all the user's email addresses, then loop them.
> On each loop grab all news items.
> Then emails results to the user and moves on to the next user.
>
> Im running this on my test box, that only has two users, but the 2nd
> user never gets the expected results.
> The first user get the message and the news.
> The second only gets the message.
> The code structure is pretty much unchanged from a working example till
> I started using $container to hold array elements.
>
> Could anyone see bad logic in the above code??
> Thanks
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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




Re: [PHP] Regular Expression Challenge

2002-03-25 Thread Christopher William Wesley

You won't be able to do that with a regexp alone.  Recursively matching
isn't possible.  You'll need a little help from some additional code.

\n" . $matches[2] . "\n" );
while( list( $key, $val ) = each( $times ) ){
print( trim( ${val} ) . "\n" );
}
?>

That seems to do the trick.  Hopefully that gets ya closer to where you
want to go.  If you really needed to regexp match on the times, you can
do that within the while loop.

g.luck,
~Chris /"\
   \ / Microsoft Security Specialist:
X  The moron in Oxymoron.
   / \ http://www.thebackrow.net

On Mon, 25 Mar 2002, Cameron Just wrote:

> Hi,
>
> I am trying to pull out the following information via a regular expression.
>
> The string I am searching on is 'wed-thurs 9:35, 14:56, 18:35'
>
> and I want it to retreive
> wed
> thurs
> 9:35
> 14:56
> 18:35
>
> The regular expression I am using is
> ([a-z]+)-([a-z]+) +([0-9]{1,2}:?[0-9]{0,2})[, ]*
>
> It seems to be grabbing the
> wed
> thurs
> 9:35
> but I can't seem to retrieve the rest of the times.
>
> Anyone have any ideas?
>
> BTW
> There can be any number of 'times' in the string and also the 'times' can
> be with or without the colon and the minutes, hence the '}:?[0-9]{0,2}'
> part of the regexp.


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




Re: [PHP] Retaining data across multiple sites

2002-02-20 Thread Christopher William Wesley

On Wed, 20 Feb 2002, Ben Sinclair wrote:

> These are all workable solutions, but I also have to worry about https sites.

I called it a "work-around" rather than a "solution" on purpose :)
The only real solution is to collapse the different sites into one domain.

> If I link to hidden images on non-secure servers, the browser will display a
> warning. I'm also trying to avoid buying multiple certificates when all I want
> to do is brand a site.

There's another pitfall.  More users want better privacy and security ...
they'll get it, some day.  Like I said before, this is just how the
Internet is evolving.  As you're doing, the functionality being provided
has to be judged against the practicality of its implementation.

g.luck,
~Chris

> ----- Original Message -
> From: "Christopher William Wesley" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Cc: "Ben Sinclair" <[EMAIL PROTECTED]>
> Sent: Wednesday, February 20, 2002 11:27 AM
> Subject: Re: [PHP] Retaining data across multiple sites
>
>
> > On Wed, 20 Feb 2002, Ben Sinclair wrote:
> >
> > > I want to retain some data across my sites, which have different domain
> names.
> > > I can't use cookies because they rely on the domain name, and I'd rather
> not
> >
> > One way I handle this ... it's a work-around, so it's not all that pretty:
> >
> > In the doc root on all the domains, I keep a script which just prints out
> > the cookie names & values for any cookies accessible by the domain ... as



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




Re: [PHP] Retaining data across multiple sites

2002-02-20 Thread Christopher William Wesley

On Wed, 20 Feb 2002, Ben Sinclair wrote:

> I want to retain some data across my sites, which have different domain names.
> I can't use cookies because they rely on the domain name, and I'd rather not

One way I handle this ... it's a work-around, so it's not all that pretty:

In the doc root on all the domains, I keep a script which just prints out
the cookie names & values for any cookies accessible by the domain ... as
JavaScript variables.  Then that script can be used as the src in a
 on any of your other domains.  BINGO ... you've got cookies!

Want milk?

On domain_A, have this script (let's call it A_cookies.php):

while( list( $key, $val ) = each( $HTTP_COOKIE_VARS ) ){
print( "var $key = \"$val\";\n" );
}

On domain_B, in an HTML document, use some JavaScript: