php-general Digest 18 May 2005 09:01:52 -0000 Issue 3461

Topics (messages 215411 through 215447):

Re: PHP Applications?
        215411 by: Greg Donald
        215426 by: Manuel Lemos
        215428 by: Danny Brow
        215436 by: Chris Shiflett
        215441 by: Richard Lynch

hey dip shit
        215412 by: Jason Motes
        215418 by: Jason Motes
        215420 by: John Nichel
        215424 by: Ryan A
        215425 by: Mary-Anne Nayler
        215430 by: Ryan A

Re: PHP Complex Data Structures
        215413 by: Jason Barnett
        215415 by: Jay Blanchard
        215427 by: Matthew Weier O'Phinney
        215445 by: zzapper

Refresh (F5) adds another SQL record.
        215414 by: Robert Meyer
        215419 by: Jay Blanchard
        215421 by: Marek Kilimajer
        215423 by: Marcus Joyce
        215433 by: Robert Meyer
        215434 by: Robert Meyer
        215440 by: Richard Lynch

Re: why are session only working with cookies?
        215416 by: Brian V Bonini

Re: array, trouble updating
        215417 by: Jason Wong
        215432 by: mayo

Mail function
        215422 by: virtualsoftware.gmail.com
        215439 by: Richard Lynch

Curious bug and crash
        215429 by: Dave Lists

Re: array, trouble updating - SOLVED
        215431 by: mayo

libxml_set_streams_context
        215435 by: Bill Hoffman
        215437 by: Richard Lynch
        215443 by: Bill Hoffman

Re: Secure delivery
        215438 by: lopopizarro.users.sourceforge.net

Re: Blank page in browser
        215442 by: Nayeem

Unknown column 'peterspeters' in 'where clause'
        215444 by: Mark Sargent
        215446 by: Tom Rogers
        215447 by: Mark Rees

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 ---
On 5/17/05, Brent Baisley <[EMAIL PROTECTED]> wrote:
> Zend sells a compiler to speed up your PHP code. Since it's compiled,
> it also does not contain the source code in readable form. You should
> visit the Zend website.

Did you have a link for this 'compiler' ?  All I see in the site menu
is a link to the encoder.  Sorry if I'm just not seeing it.


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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

on 05/17/2005 11:27 AM Brian Dunning said the following:
My background is mostly with Lasso. One cool feature is the ability to make "LassoApps" - single file applications that are secure and can be sold & distributed without providing access to the source. Does PHP offer any such capability?

You may want to try this class that generates a PHP script that self installs packages with many application files.


http://www.phpclasses.org/php2install

Then you can use a PHP compiler like RoadSend to generate executable binaries to protect the code.

http://www.roadsend.com/


--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html

--- End Message ---
--- Begin Message ---
On Tue, 2005-05-17 at 15:34 -0400, Brent Baisley wrote:
> Zend sells a compiler to speed up your PHP code. Since it's compiled, 
> it also does not contain the source code in readable form. You should 
> visit the Zend website.
> 

Any free ones?

--- End Message ---
--- Begin Message --- Danny Brow wrote:
> Zend sells a compiler to speed up your PHP code. Since it's compiled,
> it also does not contain the source code in readable form. You should
> visit the Zend website.

Any free ones?

http://pecl.php.net/package/APC

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

--- End Message ---
--- Begin Message ---
On Tue, May 17, 2005 1:50 pm, Greg Donald said:
> On 5/17/05, Brent Baisley <[EMAIL PROTECTED]> wrote:
>> Zend sells a compiler to speed up your PHP code. Since it's compiled,
>> it also does not contain the source code in readable form. You should
>> visit the Zend website.
>
> Did you have a link for this 'compiler' ?  All I see in the site menu
> is a link to the encoder.  Sorry if I'm just not seeing it.

He probably meant the encoder.

Zend has a lot of products, though, and there maybe might be one designed
just to secure your PHP source...  I kinda lost track lately, with all the
options out there.

Err, anyway, I just really wanted to say that virtually every Zend product
has been so routinely mis-represented by what it does that the amount of
mis-information out there is probably larger than the amount of correct
info.

Read Zend's website product descriptions first, and ignore forum/mailing
list comments until you're clear on what the product does, and doesn't do.

That will help you separate the patent falsehoods from useful info, and
winnow down your reading by a factor of 3.

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

--- End Message ---
--- Begin Message --- HAH
--- End Message ---
--- Begin Message --- Sorry for this post. A coworker was messing around with my computer and sent it.

Please direct all flames to [EMAIL PROTECTED]

Sorry!!

Jason Motes wrote:
HAH

--- End Message ---
--- Begin Message --- Jason Motes wrote:
HAH


This list could really use an active moderator.

--
By-Tor.com
...it's all about the Rush
http://www.by-tor.com

--- End Message ---
--- Begin Message ---
Well, I guess he was just talking to himself.

Please forward this to your pal at [EMAIL PROTECTED]

Cheers!


On 5/17/2005 11:53:20 PM, Jason Motes ([EMAIL PROTECTED]) wrote:
> Sorry for this post.  A coworker was messing around with my computer and
> sent it.
> 
> Please direct all flames to [EMAIL PROTECTED]
> 
> Sorry!!
> 
> Jason Motes wrote:
> > HAH
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.12 - Release Date: 5/17/2005

--- End Message ---
--- Begin Message --- This is a perfect example of the reason why you should lock your screen when you are away from your desk!!

Jason Motes wrote, On 18/05/05 07:53 AM:

Sorry for this post. A coworker was messing around with my computer and sent it.

Please direct all flames to [EMAIL PROTECTED]

Sorry!!

Jason Motes wrote:

HAH



--- End Message ---
--- Begin Message ---
Or why sometimes its ok to punch a friend in the mouth...


On 5/18/2005 1:42:30 AM, Mary-Anne Nayler ([EMAIL PROTECTED]) wrote:
> This is a perfect example of the reason why you should lock your screen
> when you are away from your desk!!
> 
> Jason Motes wrote, On 18/05/05 07:53 AM:
> 
> > Sorry for this post.  A coworker was messing around with my computer
> > and sent it.
> >
> > Please direct all flames to [EMAIL PROTECTED]
> >
> > Sorry!!
> >
> > Jason Motes wrote:
> >
> >> HAH
> >
> >
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.12 - Release Date: 5/17/2005

--- End Message ---
--- Begin Message --- Zzapper wrote:
Hi,
I seem to remember that you access/use PHP data in the same/similar way to Perl 
data and that you
can create complex data structures ie
arrays of arrays, arrays of records etc.

For once Google let me down so can any one point at any doc info.


<?php

class A { }

/** Initialize the array with values */
$stack = array(1,2,3);
/** Push an array on the stack */
$stack[] = array('a', '2nd dimension of array');
/** Now we show that we can push an object onto the array */
$obj = new A();
/** The & might be recommended if you're using PHP4 */
$stack[] = &$obj;
$obj->testvar = TRUE;

/** Now we look at the stack */
echo '<pre>';
var_dump($stack);
echo '</pre>';

?>
--- End Message ---
--- Begin Message ---
[snip]
I seem to remember that you access/use PHP data in the same/similar way
to Perl data and that you
can create complex data structures ie
arrays of arrays, arrays of records etc.

For once Google let me down so can any one point at any doc info.
[/snip]

Start with http://www.php.net/array

--- End Message ---
--- Begin Message ---
* Zzapper <[EMAIL PROTECTED]>:
> I seem to remember that you access/use PHP data in the same/similar
> way to Perl data and that you can create complex data structures ie
> arrays of arrays, arrays of records etc.
>
> For once Google let me down so can any one point at any doc info.

Did you try building any complex data structures? You could have whipped
out something to test pretty quickly. The quick answer is, 'Yes'. 

The longer answer is: cut-and-past the following into a script and see
what you get:

$cds = array(
    'element1' => array(
        'string1',
        'string2',
        'string3'
    ),
    'element2' => true,
    'element3' => array(
        'subelement1' => array(
            array(1, 2, 3),
            2,
            3
        )
    )
);
var_dump($cds);

You can create any complexity you want using nested arrays. Arrays in
PHP are ordered (also called indexed) unless string keys are used (in
which case they're called associative) -- and you can mix and match
styles as needed.

Additionally, you can use these structures within objects, and define
object properties on the fly.

Read through the manual about variable types if you need more
information -- and don't be afraid to experiment.

-- 
Matthew Weier O'Phinney           | WEBSITES:
Webmaster and IT Specialist       | http://www.garden.org
National Gardening Association    | http://www.kidsgardening.com
802-863-5251 x156                 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED]         | http://vermontbotanical.org

--- End Message ---
--- Begin Message ---
On 18 May 2005 01:28:07 -0000,  wrote:

>* Zzapper <[EMAIL PROTECTED]>:
>> I seem to remember that you access/use PHP data in the same/similar
>> way to Perl data and that you can create complex data structures ie
>> arrays of arrays, arrays of records etc.
>>
>> For once Google let me down so can any one point at any doc info.
>
>Did you try building any complex data structures? You could have whipped
>out something to test pretty quickly. The quick answer is, 'Yes'. 
>
>The longer answer is: cut-and-past the following into a script and see
>what you get:
>
>$cds = array(
>    'element1' => array(
>        'string1',
>        'string2',
>        'string3'
>    ),
>    'element2' => true,
>    'element3' => array(
>        'subelement1' => array(
>            array(1, 2, 3),
>            2,
>            3
>        )
>    )
>);
>var_dump($cds);
thx 4 various answers

which also lead me to 

http://uk2.php.net/manual/en/language.types.array.php Example 11-11. Recursive 
and multi-dimensional
arrays.

I seem to remember from a previous life that you can operate directly on PHP 
data, I mean you don't
have to use the PHP primitives.


-- 
zzapper
vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?"
http://www.rayninfo.co.uk/tips/ vim, zsh & success tips

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

Scenario:
1) User is presented a blank form.
2) User fills in form.
3) User submits form.
4) Record is added to database.
5) Back to 1).
All is fine to here.
6) User clicks refresh.
7) Another record is added, same data except auto-increment field.
How do I prevent these last two steps, or at least prevent a record
from being added when refresh is clicked?

Regards,

Robert 

--- End Message ---
--- Begin Message ---
[snip]
6) User clicks refresh.
7) Another record is added, same data except auto-increment field.
How do I prevent these last two steps, or at least prevent a record
from being added when refresh is clicked?
[/snip]

Test for the existence (SELECT statement with the variables therein) of
the record even on the first try, if it exists, do not add (ever again),
if it does not exist do the insert

--- End Message ---
--- Begin Message --- Robert Meyer wrote:
Hello,

Scenario:
1) User is presented a blank form.
2) User fills in form.
3) User submits form.
4) Record is added to database.
5) Back to 1).

Go really back to 1) - use redirect. After the record is added to the database, use something like:
header('Location: http://yourserver.com/form.php');
exit;


All is fine to here.
6) User clicks refresh.
7) Another record is added, same data except auto-increment field.
How do I prevent these last two steps, or at least prevent a record
from being added when refresh is clicked?

You should see a message from your browser that data is being reposted.

--- End Message ---
--- Begin Message ---
Why dont you check that data isnt being duplicated?

$query = "SELECT auto_col FROM table where col1 = $var1 & col2 = $var 3.............";
$call_query = mysql_query($query,.......
$query_data = mysql_assoc($call_query);


if(!$query_data) { do form }

else echo "information already exists in database";


Pierce

Robert Meyer wrote:

Hello,

Scenario:
1) User is presented a blank form.
2) User fills in form.
3) User submits form.
4) Record is added to database.
5) Back to 1).
All is fine to here.
6) User clicks refresh.
7) Another record is added, same data except auto-increment field.
How do I prevent these last two steps, or at least prevent a record
from being added when refresh is clicked?

Regards,

Robert




--- End Message ---
--- Begin Message ---
"Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Robert Meyer wrote:
>> Hello,
>>
>> Scenario:
>> 1) User is presented a blank form.
>> 2) User fills in form.
>> 3) User submits form.
>> 4) Record is added to database.
>> 5) Back to 1).
>
> Go really back to 1) - use redirect. After the record is added to the 
> database, use something like:
> header('Location: http://yourserver.com/form.php');
> exit;

Does this work for all browsers?

>> All is fine to here.
>> 6) User clicks refresh.
>> 7) Another record is added, same data except auto-increment field.
>> How do I prevent these last two steps, or at least prevent a record
>> from being added when refresh is clicked?
>
> You should see a message from your browser that data is being reposted.

I looked for such a message and the only thing I can find is as follows:

1) _SERVER['HTTP_ACCEPT'] and _ENV['HTTP_ACCEPT'] and change to "*/*", but I 
don't know if that is the case for all browsers, do you know?

2) _SERVER['REDIRECT_UNIQUE_ID'] and _ENV['REDIRECT_UNIQUE_ID'], 
_SERVER['REMOTE_PORT'] and _ENV['REMOTE_PORT'], _SERVER['UNIQUE_ID'] and 
_ENV['UNIQUE_ID'] change, but I don't think the values are predictable, 
especially between browsers.

Do you know of a specific message to look for and is that message the same 
for all browsers? 

--- End Message ---
--- Begin Message ---
As a last resort, I may have to do that, but that is by no means the 
preferred method.  I want to keep database access to a minimum.

I thought by this time this problem would have had a standard solution.  It 
would be nice if PHP had a function like refreshed() so one could do ... if 
(!refreshed()) { ... } ..., but I guess not.

Thanks for your input.

Regards,

Robert

"Marcus Joyce" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Why dont you check that data isnt being duplicated?
>
> $query = "SELECT auto_col FROM table where col1 = $var1 & col2 = $var 
> 3.............";
> $call_query = mysql_query($query,.......
> $query_data = mysql_assoc($call_query);
>
> if(!$query_data) { do form }
>
> else echo "information already exists in database";
>
>
> Pierce
>
> Robert Meyer wrote:
>
>>Hello,
>>
>>Scenario:
>>1) User is presented a blank form.
>>2) User fills in form.
>>3) User submits form.
>>4) Record is added to database.
>>5) Back to 1).
>>All is fine to here.
>>6) User clicks refresh.
>>7) Another record is added, same data except auto-increment field.
>>How do I prevent these last two steps, or at least prevent a record
>>from being added when refresh is clicked?
>>
>>Regards,
>>
>>Robert
>> 

--- End Message ---
--- Begin Message ---
On Tue, May 17, 2005 2:24 pm, Robert Meyer said:
> Hello,
>
> Scenario:
> 1) User is presented a blank form.

with an MD5 hash which is stored in the database as "fresh"

> 2) User fills in form.
> 3) User submits form.
> 4) Record is added to database.

That particular MD5 has is marked as "used"

> 5) Back to 1).
> All is fine to here.
> 6) User clicks refresh.
> 7) Another record is added, same data except auto-increment field.
> How do I prevent these last two steps, or at least prevent a record
> from being added when refresh is clicked?

The used MD5 hash tells you they are re-submitting the exact same form.

Now, if the real problem is that the user has a fresh new form, and fills
in the same data again by hand, then there are only two possibilities:

1. In the real world, they actually NEED two of the "same" thing in the
database, and your application should allow it.

2. In the real world, users are likely to lose track of where they are in
their data entry, and you need to provide them the context to help avoid
that. When you go back to 1) present a message like "added blah blah blah"
at the top of the screen.  Now they *KNOW* they just did blah blah blah,
and can move on to blah blah bleh.  Data entry is a sucky job.  Make it
nicer for them, eh?  You STILL need to code for the dual entry, and do
something intelligent when they mess up, but you can improve efficiency
and decrease errors (where 2 not-quite-the-same-but-really-are-the-same
entries pass your tests) if you make your application nicer to the user.

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

--- End Message ---
--- Begin Message ---
On Tue, 2005-05-17 at 15:58, Richard Lynch wrote:
> > On Tuesday 17 May 2005 21:01, Brian V Bonini wrote:
> >
> >> Still no go... Other changes in php.ini DO take effect, just not
> >> this.... I'm at a loss....
> 
> Does phpinfo() show trans_sid as "on" or "off"?

Shows it as 0 or 1 depending on how I set it at that moment...
http://gfx.gfx-design.com/php_info.php


-- 

s/:-[(/]/:-)/g


Brian        GnuPG -> KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu
======================================================================
gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
Key Info: http://gfx-design.com/keys
Linux Registered User #339825 at http://counter.li.org

--- End Message ---
--- Begin Message ---
On Tuesday 17 May 2005 21:18, mayo wrote:
> I usually work with cold fusion and took on a little project to get my
> feet wet in php and am spinning my wheels.  What I thought might be
> difficult was easy and what I thought would be a piece of cake has
> caused me much grief over the last few days.

It appears that your overall problem is a misunderstanding of how arrays 
work in PHP and how easy it is to manipulate them.

First:

> if (session_is_registered('ses_basket_items')){

In general, for practical purposes (if PHP is installed using the 
recommended default setup, ie register_globals disabled), 
session_is_registered() is deprecated and should not be used. Use:

  if (isset($_SESSION['ses_basket_items'])) { ... };


Second:

>             if ($action == "empty")
>             {
>                         while ($ses_basket_items > -1)
>                         {
>                                     array_splice ($ses_basket_name,
> $ses_basket_items, 1);
>                                     array_splice ($ses_basket_amount,
> $ses_basket_items, 1);
>                                     array_splice ($ses_basket_price,
> $ses_basket_items, 1);
>                                     array_splice ($ses_basket_id,
> $ses_basket_items, 1);
>                                     $ses_basket_items--;
>                         }
>             }

You seem to be using multiple single dimension arrays to store your basket 
details. That is not the optimal way of doing things. You should have a 
*single* multi dimension array, there are many ways to do this, here's a 
couple:

1)
  $basket[1] = array('name' => 'name of product',
                     'id' => 'product id',
                     'price' => 'price of product',
                     'amount' => 'quantity required');
  $basket[2] = array('name' => 'name of product',
                     'id' => 'product id',
                     'price' => 'price of product',
                     'amount' => 'quantity required');

2)
  $basket['a_product_id'] = array('name' => 'name of product',
                                  'price' => 'price of product',
                                  'amount' => 'quantity required');

  $basket['another_product_id'] = array('name' => 'name of product',
                                        'price' => 'price of product',
                                        'amount' => 'quantity required');


OK, so how do you operate on them? In the examples below 2 forms will be 
given corresponding to how you defined the arrays as per above.

To remove an item:

1) unset($basket[n]); // where n is an integer 
2) unset($basket['product_id']; // if product_id is an integer
                                // then you don't need the single-quotes
                                // note that also applies when first
                                // define the array, ie:
                                // $basket[product_id] = array(...);

To change an attribute, eg the amount:

1) $basket[n]['amount'] = 5;
2) $basket['product_id'] = 10;


To display an attribute, eg price:

1) echo $basket[n]['price'];
2) echo $basket['product_id']['price'];


When playing around with arrays, print_r() is your friend, use it 
liberally.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
New Year Resolution: Ignore top posted posts

--- End Message ---
--- Begin Message ---
Jason,

Thx. Even though I have what I need for the client (I finally got things
to work as desired), I'll rework it and update the client version.

I knew I was doing things poorly and it degenerated into simply "get the
damn thing to work."

Thx, Mayo



-----Original Message-----
From: Jason Wong [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 17, 2005 5:56 PM
To: [email protected]
Subject: Re: [PHP] array, trouble updating

On Tuesday 17 May 2005 21:18, mayo wrote:
> I usually work with cold fusion and took on a little project to get my
> feet wet in php and am spinning my wheels.  What I thought might be
> difficult was easy and what I thought would be a piece of cake has
> caused me much grief over the last few days.

It appears that your overall problem is a misunderstanding of how arrays

work in PHP and how easy it is to manipulate them.

First:

> if (session_is_registered('ses_basket_items')){

In general, for practical purposes (if PHP is installed using the 
recommended default setup, ie register_globals disabled), 
session_is_registered() is deprecated and should not be used. Use:

  if (isset($_SESSION['ses_basket_items'])) { ... };


Second:

>             if ($action == "empty")
>             {
>                         while ($ses_basket_items > -1)
>                         {
>                                     array_splice ($ses_basket_name,
> $ses_basket_items, 1);
>                                     array_splice ($ses_basket_amount,
> $ses_basket_items, 1);
>                                     array_splice ($ses_basket_price,
> $ses_basket_items, 1);
>                                     array_splice ($ses_basket_id,
> $ses_basket_items, 1);
>                                     $ses_basket_items--;
>                         }
>             }

You seem to be using multiple single dimension arrays to store your
basket 
details. That is not the optimal way of doing things. You should have a 
*single* multi dimension array, there are many ways to do this, here's a

couple:

1)
  $basket[1] = array('name' => 'name of product',
                     'id' => 'product id',
                     'price' => 'price of product',
                     'amount' => 'quantity required');
  $basket[2] = array('name' => 'name of product',
                     'id' => 'product id',
                     'price' => 'price of product',
                     'amount' => 'quantity required');

2)
  $basket['a_product_id'] = array('name' => 'name of product',
                                  'price' => 'price of product',
                                  'amount' => 'quantity required');

  $basket['another_product_id'] = array('name' => 'name of product',
                                        'price' => 'price of product',
                                        'amount' => 'quantity
required');


OK, so how do you operate on them? In the examples below 2 forms will be

given corresponding to how you defined the arrays as per above.

To remove an item:

1) unset($basket[n]); // where n is an integer 
2) unset($basket['product_id']; // if product_id is an integer
                                // then you don't need the single-quotes
                                // note that also applies when first
                                // define the array, ie:
                                // $basket[product_id] = array(...);

To change an attribute, eg the amount:

1) $basket[n]['amount'] = 5;
2) $basket['product_id'] = 10;


To display an attribute, eg price:

1) echo $basket[n]['price'];
2) echo $basket['product_id']['price'];


When playing around with arrays, print_r() is your friend, use it 
liberally.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
New Year Resolution: Ignore top posted posts

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

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

I have a script which send emails using mail() function. I have 100 email 
addresses and i set up the script to send 1 email every 10 seconds. So, it will 
take 1000 seconds
to send all 100 emails.

My question is: If I stop the script after,let's say 12 seconds, it will send 
only 1 email or all 100?I mean it is possible that the server to cache all 
emails and send them  if i stop the script? I must say that the script is run 
through a web browser.


Thanks in advance for your help !!!!

--- End Message ---
--- Begin Message ---
On Tue, May 17, 2005 3:53 pm, [EMAIL PROTECTED] said:
> I have a script which send emails using mail() function. I have 100 email
> addresses and i set up the script to send 1 email every 10 seconds. So, it
> will take 1000 seconds
> to send all 100 emails.
>
> My question is: If I stop the script after,let's say 12 seconds, it will
> send only 1 email or all 100?I mean it is possible that the server to
> cache all emails and send them  if i stop the script? I must say that the
> script is run through a web browser.

If you stop the script before PHP executes the instruction to send the
email,  then the email ain't gonna go out.  Period.

Your best bet would be to use PHP to QUEUE the emails up, and let your
mail sending software (sendmail, qmail, elvenmail) worry about load and
timing.

You may also want to consider having the web-based application simply set
a flag/indicator somewhere which tells PHP that it's time to queue up all
100 emails.  Then the end user won't even have to wait for 100 emails to
get queued up in line.  They only have to wait for the flag to get set
which should take, like, less than one second.

There are also innumerable PHP mail classes "out there" to make sending
email easier. http://phpclasses.org has some, I'm betting PEAR has some,
and you could Google and find a thousand more.

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

--- End Message ---
--- Begin Message --- Hi,
Tonight I installed a new php5 instance. php5.0.4/apache-1.3.33/mysql-4.1.10. I was getting "\Wed May 18 01:59:42 2005] [notice] child pid 1621 exit signal Segmentation fault (11)" error whenever I accessed a PHP enable page. I recompiled a few times and removed unnecessary modules. Still the same problem. So in order to get a debug output, I recompiled with --enable-debug. The curious thing is, now the error doesn't occur. Anyone any ideas?


Dave.
--- End Message ---
--- Begin Message ---
Yikes,

Who would have thought something so easy would be such a pain in the
butt.

I solved it with embedded if-else clauses.

Thx all



-----Original Message-----
From: mayo [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 17, 2005 9:19 AM
To: 'php'
Subject: [PHP] array, trouble updating

I usually work with cold fusion and took on a little project to get my
feet wet in php and am spinning my wheels.  What I thought might be
difficult was easy and what I thought would be a piece of cake has
caused me much grief over the last few days.
 
I'm making a little shopping basket, writing the results to a file,
ftping the file to a distributor and sending the CC data to merchant
services company.
 
Write to file - easy
FTP file to distributor - easy
Updating the array in the shopping basket -- not so easy !!??!!
 
A shopping basket should be able to add and delete items (done)
You should be able to delete the whole basket (done)
Now I need to be able to update quantity - I've spent at least 5 or 6
hours on this and have gotten nowhere!!! This learning exercise is
getting to be a major time drag.
 
Any hints would be good. 
 
The code is below:
 
 
<?php
 
            if ($action == "empty") 
            { 
                        while ($ses_basket_items > -1) 
                        { 
                                    array_splice ($ses_basket_name,
$ses_basket_items, 1); 
                                    array_splice ($ses_basket_amount,
$ses_basket_items, 1); 
                                    array_splice ($ses_basket_price,
$ses_basket_items, 1); 
                                    array_splice ($ses_basket_id,
$ses_basket_items, 1); 
                                    $ses_basket_items--; 
                        } 
            } 
 
            if ($action2 == "deleteItem") 
            { 
                        array_splice ($ses_basket_name, $position, 1); 
                        array_splice ($ses_basket_amount, $position, 1);

                        array_splice ($ses_basket_price, $position, 1); 
                        array_splice ($ses_basket_id, $position, 1); 
                        $ses_basket_items--;
            } 
 
?>
<?php 
 
if ($_GET['basket']!=""){ 
if (session_is_registered('ses_basket_items')){ 
$basket_position_counter=0; 
$double=0; 
if ($_SESSION['ses_basket_items']>0){ 
foreach ($_SESSION['ses_basket_name'] as $basket_item){ 
if ($basket_item==$_GET['basket']){ 
$double=1; 
$subtract=1;
$basket_position=$basket_position_counter; 
 
} 
$basket_position_counter++; 
} 
} 
 
if ($double==1){ 
                        
            $oldamount=$_SESSION['ses_basket_amount'][$basket_position];

            $_SESSION['ses_basket_amount'][$basket_position]++; 
            $amount=$_SESSION['ses_basket_amount'][$basket_position]; 
            $oldprice=$_SESSION['ses_basket_price'][$basket_position]; 
            $newprice=($oldprice/$oldamount)*$amount; 
            $_SESSION['ses_basket_price'][$basket_position]=$newprice; 
 
}else{ 
            $_SESSION['ses_basket_name'][]=$_GET['basket']; 
            $_SESSION['ses_basket_amount'][]=1; 
            $_SESSION['ses_basket_price'][]=$_GET['price']; 
            $_SESSION['ses_basket_id'][]=$_GET['id']; 
            $_SESSION['ses_basket_items']++; 
} 
}else{ 
 
            $_SESSION['ses_basket_items']=1; 
            $_SESSION['ses_basket_name'][0]=$_GET['basket']; 
            $_SESSION['ses_basket_amount'][0]=1; 
            $_SESSION['ses_basket_price'][0]=$_GET['price']; 
            $_SESSION['ses_basket_id'][0]=$_GET['id']; 
            session_register("ses_basket_items"); 
            session_register("ses_basket_name"); 
            session_register("ses_basket_amount"); 
            session_register("ses_basket_price"); 
            session_register("ses_basket_id"); 
} 
} 
 
            
if ($_SESSION['ses_basket_items']>0){ 
 
for
($basket_counter=0;$basket_counter<$_SESSION['ses_basket_items'];$basket
_counter++){ 
// basket output 
$price=sprintf("%01.2f",$_SESSION['ses_basket_price'][$basket_counter]);

$amount=$_SESSION['ses_basket_amount'][$basket_counter]; 
$name=$_SESSION['ses_basket_name'][$basket_counter]; 
$aaa=$basket_counter;
 
echo "$amount $name $price";
echo "<a href=\"2.php?action2=deleteItem&position=" . $aaa .
"\">DEL</a>";
echo "<a
href=\"2.php?id=1001&price=25&basket=mouse&subtract=yes\">-sub</a>";
echo "$aaa";
 
echo "<BR>\n"; 
} 
} else { 
 
$_SESSION['ses_basket_items']=0; 
unset($_SESSION['ses_basket_name']); 
unset($_SESSION['ses_basket_amount']); 
unset($_SESSION['ses_basket_price']); 
unset($_SESSION['ses_basket_id']); 
} 
 
?>
 

--- End Message ---
--- Begin Message --- I'm trying to use libxml_set_streams_context() to load a remote xml file via HTTP conditional GET with DOMDocument::load() by stuffing an 'If-Modified-Since: --- " HTTP header into the stream, but no matter how I try it I always get an HTTP 200 response when I know the last- modified date is well before my if-modified date string.

I've confirmed via curl -H on the command line that I can do it properly and get an HTTP 304 as expected, but I don't know what I'm not doing right with libxml_set_streams_context(). Here's my code:

$opts = array('http'=>array('method'=>"GET", 'header'=>"If-Modified- Since: Wed, 18 May 2005 23:55:29 GMT\r\n"));
$context = stream_context_create($opts);
libxml_set_streams_context($context);
$doc->load('http://www.somewhere.com/somefile.xml');
echo $doc->saveXML();


using the same $context resource, this also produces the same result, when I expect it should work.

file_get_contents('http://www.somewhere.com/somefile.xml', false, $context);

I have php 5.0.4 compiled with libxml2 (2.6.16) on Mac OS X 10.4. I imagine I'm not doing something correctly, but can't figure out what it is.

Any help?

--
Bill Hoffman
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
On Tue, May 17, 2005 9:03 pm, Bill Hoffman said:
> I'm trying to use libxml_set_streams_context() to load a remote xml
> file via HTTP conditional GET with DOMDocument::load() by stuffing an
> 'If-Modified-Since: --- " HTTP header into the stream, but no matter
> how I try it I always get an HTTP 200 response when I know the last-
> modified date is well before my if-modified date string.
>
> I've confirmed via curl -H on the command line that I can do it
> properly and get an HTTP 304 as expected, but I don't know what I'm
> not doing right with libxml_set_streams_context(). Here's my code:
>
> $opts = array('http'=>array('method'=>"GET", 'header'=>"If-Modified-
> Since: Wed, 18 May 2005 23:55:29 GMT\r\n"));
> $context = stream_context_create($opts);
> libxml_set_streams_context($context);
> $doc->load('http://www.somewhere.com/somefile.xml');
> echo $doc->saveXML();

Where is your error checking?

I don't know much about that fancy new stream stuff, or the XML crap, but
you've got zero (0) lines of code in there to do anything useful when the
functions fail.

If you ask the functions nicely, they almost always tell you EXACTLY what
went wrong.

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

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


On May 17, 2005, at 10:24 PM, Richard Lynch wrote:

I don't know much about that fancy new stream stuff, or the XML crap, but
you've got zero (0) lines of code in there to do anything useful when the
functions fail.

no functions fail.

what I'm expecting is that with libxml_set_streams_context(), I've correctly sent an HTTP "If-Modified-Since" Request Header along with the HTTP GET in the DOMDocument::load() call. what I'm seeing is that somehow I haven't, since the the DOMDocument::load() call returns the file (with an HTTP 200 status in the response header) even though I know the file has not been modified since the "If-Modified-Since" date (confirmed by looking at the "Last-Modified" date in the response header).

the fact that there is no failure, and no error message that I can examine or test is exactly why I'm scratching my head and asking if anyone who does know something about stream contexts can offer some pointers.

I don't think I need any help with "the XML crap", as you put it.
--- End Message ---
--- Begin Message ---
Please authenticate the secure message.


+++ Attachment: No Virus found
+++ Bitdefender AntiVirus - www.bitdefender.com


--- End Message ---
--- Begin Message ---
Thanks Richard Lynch,

I found same error in error_log file which I face on command prompt before
then I install PHP 5.0 with --with-oci8=$ORACLE_HOME compilation so that
problem solved. Now I'm facing same problem on Apache. So can you tell me
where should I define the environment variables on Apache.

Thanks,

Regards,
Nayeem.

-----Original Message-----
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 17, 2005 10:51 PM
To: Nayeem
Cc: [email protected]
Subject: Re: [PHP] Blank page in browser

On Tue, May 17, 2005 1:41 am, Nayeem said:
> I'm new to PHP programming and I just try to display small information
> from
> database on web page but its shows blank page. So my code is mention below
> and let me know what's wrong in it but when I execute same program on
> command prompt then its shows all result correctly with HTML Tags

You logged in as you.
The PHP user runs as somebody else.

That other user does not have the same permissions/rights as you, and not
the same environment variables ($PATH in shell) and not even the same
shell.

If you can 'su' to that other user and run it, you may find out why it
fails.  You should also check error logs as suggested, and use "View
Source" in your browser to see if the "blank" page is really blank, or
just buried inside an unfinished HTML tag.

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

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

the below code generates this error,

Unknown column 'peterspeters' in 'where clause'

mysql_select_db("status", $db);
$username = $_POST["username"];
$password = $_POST["password"];
$result = mysql_query("SELECT customer_id FROM Customers WHERE customer_username = $username AND customer_password = $password") or die (mysql_error());
$myrow = mysql_fetch_row($result);
$customer_id = $myrow[0];
$_SESSION['customer_id'] = $customer_id;
?>
</head>
<body>
<?php
echo 'SQL Query: '.$result.'<br>';
echo "CustomerID = $customer_id";
?>


Cheers.

Mark Sargent.
--- End Message ---
--- Begin Message ---
Hi,

Wednesday, May 18, 2005, 4:27:34 PM, you wrote:
MS> Hi All,

MS> the below code generates this error,

MS> Unknown column 'peterspeters' in 'where clause'

MS> mysql_select_db("status", $db);
MS> $username = $_POST["username"];
MS> $password = $_POST["password"];
MS> $result = mysql_query("SELECT customer_id FROM Customers WHERE 
MS> customer_username = $username AND customer_password = $password") or die
MS> (mysql_error());
MS> $myrow = mysql_fetch_row($result);
MS> $customer_id = $myrow[0];
MS> $_SESSION['customer_id'] = $customer_id;
?>>
MS> </head>
MS> <body>
MS> <?php
MS> echo 'SQL Query: '.$result.'<br>';
MS> echo "CustomerID = $customer_id";
?>>

MS> Cheers.

MS> Mark Sargent.


You need to put the variables in single quotes, otherwise mysql treats
it as a column name. You should also escape the strings to be safe if
magic_quotes are turned off in php.ini

A bit like this:

mysql_select_db("status", $db);
$username = mysql_escape_string($_POST["username"]);
$password = mysql_escape_string($_POST["password"]);
$result = mysql_query("
        SELECT customer_id 
        FROM Customers 
        WHERE customer_username = '$username' 
        AND customer_password = '$password'") or die (mysql_error());
$myrow = mysql_fetch_row($result);
$customer_id = $myrow[0];
$_SESSION['customer_id'] = $customer_id;

-- 
regards,
Tom

--- End Message ---
--- Begin Message ---
I expect (indeed I sincerely hope) that customer_username  AND
customer_password columns are character datatypes. So it would be a good
idea to put single quotes around the values you are trying to select
from them.

-----Original Message-----
From: Mark Sargent [mailto:[EMAIL PROTECTED] 
Sent: 18 May 2005 07:28
To: [email protected]
Subject: [PHP] Unknown column 'peterspeters' in 'where clause'


Hi All,

the below code generates this error,

Unknown column 'peterspeters' in 'where clause'

mysql_select_db("status", $db);
$username = $_POST["username"];
$password = $_POST["password"];
$result = mysql_query("SELECT customer_id FROM Customers WHERE 
customer_username = $username AND customer_password = $password") or die

(mysql_error());
$myrow = mysql_fetch_row($result);
$customer_id = $myrow[0];
$_SESSION['customer_id'] = $customer_id;
?>
</head>
<body>
<?php
echo 'SQL Query: '.$result.'<br>';
echo "CustomerID = $customer_id";
?>

Cheers.

Mark Sargent.

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

Gamma Global : Suppliers of HPCompaq, IBM, Acer, EPI, APC, Cyclades, D-Link, 
Cisco, Sun Microsystems, 3Com

GAMMA GLOBAL (UK) LTD IS A RECOGNISED 'INVESTOR IN PEOPLE' AND AN 'ISO 9001 
2000' REGISTERED COMPANY

**********************************************************************

CONFIDENTIALITY NOTICE:

This Email is confidential and may also be privileged. If you are not the
intended recipient, please notify the sender IMMEDIATELY; you should not
copy the email or use it for any purpose or disclose its contents to any
other person.

GENERAL STATEMENT:

Any statements made, or intentions expressed in this communication may not
necessarily reflect the view of Gamma Global (UK) Ltd. Be advised that no 
content
herein may be held binding upon Gamma Global (UK) Ltd or any associated company
unless confirmed by the issuance of a formal contractual document or
Purchase Order,  subject to our Terms and Conditions available from 
http://www.gammaglobal.com

E&OE

**********************************************************************
**********************************************************************


--- End Message ---

Reply via email to