RE: [PHP] Radio buttons problem

2009-08-10 Thread leledumbo

> Why do you? There's no reason you *have* to have consecutive indexes --
just iterate over the resulting > array with foreach, and there's no
problem.

There is, the entries are grouped by its index. So, I group name[0],
email[0], and sex[0] as one. The problem if I don't maintain the index for
radio buttons, the index could go wrong.

In the previous example I gave, if entry2 is deleted (and I don't maintain
the index) then entry3 will contain name[1], email[1], and sex[2] which
isn't desirable.
-- 
View this message in context: 
http://www.nabble.com/Radio-buttons-problem-tp24786766p24897287.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] MySQL auto_increment fields Server version: 5.1.32-community-log

2009-08-10 Thread tedd

At 12:47 AM +0200 8/10/09, Ralph Deffke wrote:

I would like to have a KNOWN status of my database after a NEW installation
of the application, because the further installation relais on information
stored in record 1 of each table.


Sounds like a problem waiting to happen.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



RE: [PHP] Server change affecting ability to send downloaded files???

2009-08-10 Thread Ford, Mike


> -Original Message-
> From: Brian Dunning [mailto:br...@briandunning.com]
> Sent: 08 August 2009 01:04
> To: PHP General List
> Subject: Re: [PHP] Server change affecting ability to send
> downloaded files???
> 
> Very interesting. Excellent debugging advice. It's giving me a 500
> error, probably why the Rackspace techs told me to check my code:
> 
> HTTP/1.0 500 Internal Server Error
> Date: Sat, 08 Aug 2009 00:01:10 GMT
> Server: Apache/2.0.52 (Red Hat)
> X-Powered-By: PHP/5.2.10
> Content-Disposition: attachment; filename="Installer.bin"
> Content-Length: 23223296
> Connection: close
> Content-Type: application/octet-stream
> 
> I'm at a loss. Nothing changed in the code and it works for ZIP
> files.

I notice the X-Powered-By header shows you are running on PHP 5.2.10.  This was 
released on 18-June-2009, so Rackspace must have upgraded your PHP installation 
some time after that.  I think it's a reasonable assumption that something is 
behaving differently in PHP 5.2.10 from how it did in whatever version you were 
running under before.  You need to track down what that something is, and fix 
it!


Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] Radio buttons problem

2009-08-10 Thread Ford, Mike


> -Original Message-
> From: leledumbo [mailto:leledumbo_c...@yahoo.co.id]
> Sent: 10 August 2009 11:11
> To: php-general@lists.php.net
> Subject: RE: [PHP] Radio buttons problem
> 
> 
> > Why do you? There's no reason you *have* to have consecutive
> indexes --
> just iterate over the resulting > array with foreach, and there's no
> problem.
> 
> There is, the entries are grouped by its index. So, I group name[0],
> email[0], and sex[0] as one. The problem if I don't maintain the
> index for
> radio buttons, the index could go wrong.
> 
> In the previous example I gave, if entry2 is deleted (and I don't
> maintain
> the index) then entry3 will contain name[1], email[1], and sex[2]
> which
> isn't desirable.

Huh???

If you have entries for:

   name[0], email[0], sex[0]
   name[1], email[1], sex[1]
   name[2], email[2], sex[2]
   ...

and then delete the entry containing sex[1], why wouldn't you just end up with

   name[0], email[0], sex[0]
   name[2], email[2], sex[2]
   ...

???

Unless, of course, what you have is

   name[], email[], sex[0]
   name[], email[], sex[1]
   name[], email[], sex[2]
   ...

... in which case, don't do that!  If it's important to you that the indexes 
match across name[], email[] and sex[], then you must supply them explicitly 
for every field in the group -- if you name some of the fields with [], and 
some with explicit [1], [2] indexes, you're setting yourself up for exactly 
this kind of mismatch problem when you come to delete (or insert!) entries.

Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



[PHP] Array

2009-08-10 Thread Ron Piggott
How do I change this ELSEIF into an array?

} elseif ( ( $page <> "" ) AND ( $page <> "home_page" ) AND ( $page <> 
"verse_of_the_day_activate" ) AND ( $page <> "member_services" ) AND ( $page <> 
"member_services_login" ) AND ( $page <> "member_services_logoff" ) AND ( $page 
<> "resource_center" ) AND ( $page <> "network" ) ) {

Re: [PHP] Array

2009-08-10 Thread Jonathan Tapicer
On Mon, Aug 10, 2009 at 9:28 AM, Ron
Piggott wrote:
> How do I change this ELSEIF into an array?
>
> } elseif ( ( $page <> "" ) AND ( $page <> "home_page" ) AND ( $page <> 
> "verse_of_the_day_activate" ) AND ( $page <> "member_services" ) AND ( $page 
> <> "member_services_login" ) AND ( $page <> "member_services_logoff" ) AND ( 
> $page <> "resource_center" ) AND ( $page <> "network" ) ) {

Something like:

} elseif (!in_array($page, array("", "home_page",
"verse_of_the_day_activate", ...))) {

should work.

Regards,

Jonathan

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



Re: [PHP] Array

2009-08-10 Thread Robert Cummings

Ron Piggott wrote:

How do I change this ELSEIF into an array?

} elseif ( ( $page <> "" ) AND ( $page <> "home_page" ) AND ( $page <> "verse_of_the_day_activate" ) AND ( $page <> "member_services" ) AND ( 
$page <> "member_services_login" ) AND ( $page <> "member_services_logoff" ) AND ( $page <> "resource_center" ) AND ( $page <> "network" ) ) {


Put all the compared values into an array, then check that $page is not 
in_array().


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



[PHP] Is there any considerations for not putting php scripts in tmpfs?

2009-08-10 Thread Peter Wang
Hi php-general,
sorry if it is a wrong lists for this question.

I have read many articles/messages about using tmpfs store temp files,

for example, php session data, smarty compied templates and so on.

An obvious reason for that is: it doesn't matter about data loss caused by
machine restart/poweroff.

since it is not that difficult to restore files on a tmpfs from a disk-based
dir when machine boot up.

so may i put all my php scripts on a tmpfs to speed it up?  would that cause
other issues?

thanks for your advices.


Re: [PHP] Is there any considerations for not putting php scripts in tmpfs?

2009-08-10 Thread Richard Quadling
2009/8/10 Peter Wang :
> Hi php-general,
> sorry if it is a wrong lists for this question.
>
> I have read many articles/messages about using tmpfs store temp files,
>
> for example, php session data, smarty compied templates and so on.
>
> An obvious reason for that is: it doesn't matter about data loss caused by
> machine restart/poweroff.
>
> since it is not that difficult to restore files on a tmpfs from a disk-based
> dir when machine boot up.
>
> so may i put all my php scripts on a tmpfs to speed it up?  would that cause
> other issues?
>
> thanks for your advices.
>

Considering that in the main PHP scripts are readonly, I would have
thought the normal file and disk caching of the OS would suffice.



-- 
-
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Is there any considerations for not putting php scripts in tmpfs?

2009-08-10 Thread Peter Wang
hi,thanks for your reply.



On Mon, Aug 10, 2009 at 9:54 PM, Richard Quadling
wrote:

> 2009/8/10 Peter Wang :
> > Hi php-general,
> > sorry if it is a wrong lists for this question.
> >
> > I have read many articles/messages about using tmpfs store temp files,
> >
> > for example, php session data, smarty compied templates and so on.
> >
> > An obvious reason for that is: it doesn't matter about data loss caused
> by
> > machine restart/poweroff.
> >
> > since it is not that difficult to restore files on a tmpfs from a
> disk-based
> > dir when machine boot up.
> >
> > so may i put all my php scripts on a tmpfs to speed it up?  would that
> cause
> > other issues?
> >
> > thanks for your advices.
> >
>
> Considering that in the main PHP scripts are readonly, I would have
> thought the normal file and disk caching of the OS would suffice.


normal file/disk caching of the OS works for small amount of files,
but when your apps has huge amounts of files, that doesn't work any more.
even with APC, it still cause many stat() system calls.


>
>
>
>
> --
> -
> Richard Quadling
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> "Standing on the shoulders of some very clever giants!"
> ZOPA : http://uk.zopa.com/member/RQuadling
>


RE: [PHP] Radio buttons problem

2009-08-10 Thread tedd

 > -Original Message-

 From: leledumbo [mailto:leledumbo_c...@yahoo.co.id]
 Sent: 10 August 2009 11:11
 To: php-general@lists.php.net

 > Subject: RE: [PHP] Radio buttons problem



 > There is, the entries are grouped by its index. So, I group name[0],

 email[0], and sex[0] as one. The problem if I don't maintain the

 > index for radio buttons, the index could go wrong.



This is far more complicated than it needs to be.

Check this out:

http://php1.net/b/form-radio/

In addition to 'option[]', I certainly can add additional radio 
groups for name[], email[], and sex[].


The solution is  -- DO NOT force adding an index to each array, such 
as name[0], email[0], sex[0], but rather let it be name[], email[], 
and sex[].


If you try it, it will work.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Array

2009-08-10 Thread Jim Lucas
Ron Piggott wrote:
> How do I change this ELSEIF into an array?
> 
> } elseif ( ( $page <> "" ) AND ( $page <> "home_page" ) AND ( $page <> 
> "verse_of_the_day_activate" ) AND ( $page <> "member_services" ) AND ( $page 
> <> "member_services_login" ) AND ( $page <> "member_services_logoff" ) AND ( 
> $page <> "resource_center" ) AND ( $page <> "network" ) ) {




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



[PHP] Re: Array

2009-08-10 Thread Colin Guthrie

'Twas brillig, and Jim Lucas at 10/08/09 16:29 did gyre and gimble:

$d = array(
"home_page",
"member_services",
"member_services_login",
"network",
"resource_center",
"verse_of_the_day_activate",
);


Ahh someone else who always puts a closing , on the end of array 
definitions to cut down on VCS diff/patch churn. Excellent :)


Col

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



Re: [PHP] reason for a "Notice:.." on one site but not another? (Same code.)

2009-08-10 Thread Shawn McKenzie
John Butler wrote:
>> if(isset($_POST['UserWishesDateRange']) && $_POST['UserWishesDateRange']
>> == 'T') {
> 
> 
> Thought I tried that.  Apparently not exactly; it works now!  Thanks.  I
> know it is clunky but I wanted to see how compact it could be done.

If you switch it around you'll get a notice because the IF evaluates
from left to right.  So you just want to make sure you check isset() first.

This would throw a notice:

if($_POST['UserWishesDateRange']  == 'T' &&
isset($_POST['UserWishesDateRange'])) {


-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Re: Array

2009-08-10 Thread Robert Cummings

Colin Guthrie wrote:

'Twas brillig, and Jim Lucas at 10/08/09 16:29 did gyre and gimble:

$d = array(
"home_page",
"member_services",
"member_services_login",
"network",
"resource_center",
"verse_of_the_day_activate",
);


Ahh someone else who always puts a closing , on the end of array 
definitions to cut down on VCS diff/patch churn. Excellent :)


I do it too since it makes life simple when commenting in and out chunks 
of code.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] reason for a "Notice:.." on one site but not another? (Same code.)

2009-08-10 Thread John Butler



If you switch it around you'll get a notice because the IF evaluates
from left to right.  So you just want to make sure you check isset()  
first.


This would throw a notice:

if($_POST['UserWishesDateRange']  == 'T' &&
isset($_POST['UserWishesDateRange'])) {


Aha!  That must be what I tried and was still getting the notice!   
Interesting that it works (without notice) if we check against the  
isset () one first.   It makes if() look more intelligent that I would  
think... as if it saying, "good now that we've established that the  
var isset, now is it also equal to '___'., as opposed to just, "is var  
set, and is var equal to "___'.

Re: [PHP] reason for a "Notice:.." on one site but not another? (Same code.)

2009-08-10 Thread Martin Scotta
Why do you all always use isset?
Why do you don't use array_key_exists instead? is it a more semantic
solution?

wrote:

>
>>>  If you switch it around you'll get a notice because the IF evaluates
>> from left to right.  So you just want to make sure you check isset()
>> first.
>>
>> This would throw a notice:
>>
>> if($_POST['UserWishesDateRange']  == 'T' &&
>> isset($_POST['UserWishesDateRange'])) {
>>
>
> Aha!  That must be what I tried and was still getting the notice!
>  Interesting that it works (without notice) if we check against the isset ()
> one first.   It makes if() look more intelligent that I would think... as if
> it saying, "good now that we've established that the var isset, now is it
> also equal to '___'., as opposed to just, "is var set, and is var equal to
> "___'.




-- 
Martin Scotta


Re: [PHP] reason for a "Notice:.." on one site but not another? (Same code.)

2009-08-10 Thread Ralph Deffke
this is not "intelligence" its just pure math. the '&&' says if BOTH
expressions are true then the whole expression is true.

so if the first one is false, the whole is false, why checking the next one
in the underlaying C it would be something like this
{
if ( expression == false ) return false;
if ( expression == false) return false;
return true;
}

ralph
ralph_def...@yahoo.de

"John Butler"  wrote in message
news:9ada6df4-649c-4790-b51b-cc9cc0505...@gmail.com...
> >>
> > If you switch it around you'll get a notice because the IF evaluates
> > from left to right.  So you just want to make sure you check isset()
> > first.
> >
> > This would throw a notice:
> >
> > if($_POST['UserWishesDateRange']  == 'T' &&
> > isset($_POST['UserWishesDateRange'])) {
>
> Aha!  That must be what I tried and was still getting the notice!
> Interesting that it works (without notice) if we check against the
> isset () one first.   It makes if() look more intelligent that I would
> think... as if it saying, "good now that we've established that the
> var isset, now is it also equal to '___'., as opposed to just, "is var
> set, and is var equal to "___'.



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



Re: [PHP] reason for a "Notice:.." on one site but not another? (Same code.)

2009-08-10 Thread Eddie Drapkin
On Mon, Aug 10, 2009 at 1:07 PM, Martin Scotta wrote:
> Why do you all always use isset?
> Why do you don't use array_key_exists instead? is it a more semantic
> solution?
>
> 
> $key = 'UserWishesDateRange'; # just to make statement shorter
> if( array_key_exists($key, $_POST ) && 'T' == $_POST[$key] )
> {
>    echo ' the key exists... and it is a "T" '';
> }
>
> *isset*: Determine if a variable is set and is not NULL*
> array_key_exists: *Checks if the given key or index exists in the array
>
>
> On Mon, Aug 10, 2009 at 1:42 PM, John Butler
> wrote:
>
>>
  If you switch it around you'll get a notice because the IF evaluates
>>> from left to right.  So you just want to make sure you check isset()
>>> first.
>>>
>>> This would throw a notice:
>>>
>>> if($_POST['UserWishesDateRange']  == 'T' &&
>>> isset($_POST['UserWishesDateRange'])) {
>>>
>>
>> Aha!  That must be what I tried and was still getting the notice!
>>  Interesting that it works (without notice) if we check against the isset ()
>> one first.   It makes if() look more intelligent that I would think... as if
>> it saying, "good now that we've established that the var isset, now is it
>> also equal to '___'., as opposed to just, "is var set, and is var equal to
>> "___'.
>
>
>
>
> --
> Martin Scotta
>

Two reasons:
1. isset() is orders of magnitude faster
2. The theory is, if a variable is null you don't care about it

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



Re: [PHP] reason for a "Notice:.." on one site but not another? (Same code.)

2009-08-10 Thread John Butler



If you switch it around you'll get a notice because the IF evaluates
from left to right.  So you just want to make sure you check isset()
first.

This would throw a notice:

if($_POST['UserWishesDateRange']  == 'T' &&
isset($_POST['UserWishesDateRange'])) {


Aha!  That must be what I tried and was still getting the notice!
Interesting that it works (without notice) if we check against the
isset () one first.   It makes if() look more intelligent that I  
would

think... as if it saying, "good now that we've established that the
var isset, now is it also equal to '___'., as opposed to just, "is  
var

set, and is var equal to "___'.




this is not "intelligence" its just pure math. the '&&' says if BOTH
expressions are true then the whole expression is true.

so if the first one is false, the whole is false, why checking the  
next one

in the underlaying C it would be something like this
{
if ( expression == false ) return false;
if ( expression == false) return false;
return true;
}


I would have thought both would have to be true on their own (without  
notice) in order for the the combined expression to be true (without  
notice).  But Shawn pointed out that the order matters; if we check  
for the var's value before checking if it isset then we get a notice,  
but if the order is reversed, then we get no notice.

Re: [PHP] reason for a "Notice:.." on one site but not another? (Same code.)

2009-08-10 Thread Andrew Ballard
On Mon, Aug 10, 2009 at 1:50 PM, Ralph Deffke wrote:
> this is not "intelligence" its just pure math. the '&&' says if BOTH
> expressions are true then the whole expression is true.
>
> so if the first one is false, the whole is false, why checking the next one
> in the underlaying C it would be something like this
> {
> if ( expression == false ) return false;
> if ( expression == false) return false;
> return true;
> }
>
> ralph
> ralph_def...@yahoo.de

That's logically correct, and while PHP does implement this
"short-circuit" logic, not all languages do. In that regard, I
appreciate what John meant by saying it makes it look "more
intelligent." Some languages evaluate each of the conditions to their
respective boolean results before evaluating the logical operators.

Andrew

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



Re: [PHP] reason for a "Notice:.." on one site but not another? (Same code.)

2009-08-10 Thread Martin Scotta
This "intelligence" is given by the laziness of the && operator.

$res = a() && b(); # if a() is false then b() does not evaluate
$res = a() & b(); # b() evaluates no matter a()'s result

so, order matters.

On Mon, Aug 10, 2009 at 3:29 PM, Andrew Ballard  wrote:

> On Mon, Aug 10, 2009 at 1:50 PM, Ralph Deffke
> wrote:
> > this is not "intelligence" its just pure math. the '&&' says if BOTH
> > expressions are true then the whole expression is true.
> >
> > so if the first one is false, the whole is false, why checking the next
> one
> > in the underlaying C it would be something like this
> > {
> > if ( expression == false ) return false;
> > if ( expression == false) return false;
> > return true;
> > }
> >
> > ralph
> > ralph_def...@yahoo.de
>
> That's logically correct, and while PHP does implement this
> "short-circuit" logic, not all languages do. In that regard, I
> appreciate what John meant by saying it makes it look "more
> intelligent." Some languages evaluate each of the conditions to their
> respective boolean results before evaluating the logical operators.
>
> Andrew
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Martin Scotta


AW: [PHP] reason for a "Notice:.." on one site but not another? (Same code.)

2009-08-10 Thread Ralph Deffke
the single & is a logical AND so a() NOR b() is evaluatet ! its usually used on 
binary integer.
e.g. 0x0001 & 0x0001 = 0x0001 equlals TRUE while 0x0002 & 0x0001 equals FALSE 

so something like $a & $b guides to some very interisting results depending of 
their values
but nothing u expect.

while && tells 'evaluate' the expressions on both sites and combine its results 
in an AND operation.

thats why compilers and interpreters do have a definition what value TRUE has.
its very likely that TRUE is 1 and false is 0

lets say 
$a = 1
$b = 1

then 
$a & $b is 1 or true and it would give the same like
$a && $b in that case

at that point its also to mention that an empty string in PHP is NOT == FALSE

this gives the following result on an empty string:
$a = "";
isset( $a ) == TRUE

while
$a = null;
isset( $a ) == FALSE;

for the same story there are the
==
===
and
!=
!===
operators






Von: Martin Scotta 
An: Andrew Ballard 
CC: Ralph Deffke ; php-gene...@lists..php.net
Gesendet: Montag, den 10. August 2009, 20:40:19 Uhr
Betreff: Re: [PHP] reason for a "Notice:.." on one site but not another? (Same  
code.)

This "intelligence" is given by the laziness of the && operator.

$res = a() && b(); # if a() is false then b() does not evaluate
$res = a() & b(); # b() evaluates no matter a()'s result

so, order matters.


On Mon, Aug 10, 2009 at 3:29 PM, Andrew Ballard  wrote:

On Mon, Aug 10, 2009 at 1:50 PM, Ralph Deffke wrote:
>>> this is not "intelligence" its just pure math. the '&&' says if BOTH
>>> expressions are true then the whole expression is true.
>>>
>>> so if the first one is false, the whole is false, why checking the next one
>>> in the underlaying C it would be something like this
>>> {
>>> if ( expression == false ) return false;
>>> if ( expression == false) return false;
>>> return true;
>>> }
>>>
>>> ralph
>>> ralph_def...@yahoo.de
>
>That's logically correct, and while PHP does implement this
>>"short-circuit" logic, not all languages do. In that regard, I
>>appreciate what John meant by saying it makes it look "more
>>intelligent." Some languages evaluate each of the conditions to their
>>respective boolean results before evaluating the logical operators.
>
>>Andrew
>
>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Martin Scotta



  

Re: [PHP] reason for a "Notice:.." on one site but not another? (Same code.)

2009-08-10 Thread Adam Randall
That should be !== not !===

Adam.

On Mon, Aug 10, 2009 at 12:17 PM, Ralph Deffke wrote:
> for the same story there are the

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



[PHP] Embedded foreach loops

2009-08-10 Thread Allen McCabe
I am creating an order form for tickets for a list of performances at a
performing arts center.

Currently, the form is on paper, and is set up as follows:
-Nutcracker - Tues 10/13 - 11am - $4.00


Re: [PHP] Re: Array

2009-08-10 Thread Jim Lucas
Robert Cummings wrote:
> Colin Guthrie wrote:
>> 'Twas brillig, and Jim Lucas at 10/08/09 16:29 did gyre and gimble:
>>> $d = array(
>>> "home_page",
>>> "member_services",
>>> "member_services_login",
>>> "network",
>>> "resource_center",
>>> "verse_of_the_day_activate",
>>> );
>>
>> Ahh someone else who always puts a closing , on the end of array
>> definitions to cut down on VCS diff/patch churn. Excellent :)
> 
> I do it too since it makes life simple when commenting in and out chunks
> of code.
> 
> Cheers,
> Rob.

Yes, it does make life a little easier!


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



Re: [PHP] Embedded foreach loops

2009-08-10 Thread Jim Lucas
Allen McCabe wrote:
> I am creating an order form for tickets for a list of performances at a
> performing arts center.
> 
> Currently, the form is on paper, and is set up as follows:
> -Nutcracker - Tues 10/13 - 11am - $4.00
> 

Thanks for letting us know about your new order form.

Did you have a question about something?  Or simply wanted to let us know?

Jim


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



[PHP] Embedding foreach loops

2009-08-10 Thread Allen McCabe
Gmail automatically sent my last email, apologies.

I am creating an order form for tickets for a list of performances at a
performing arts center.

Currently, the form is on paper, and is set up as follows:
-Title - date  - time - price - soldout - quantity - total($)
-Nutcracker - Tues 10/13 -  9am - $4.00 - yes/no  -  - __
-Nutcracker - Tues 10/13 - 11am - $4.00 - yes/no  -  - __
-Mayhem P.. - Thur 01/21 -  9am - $4.00 - yes/no  -  - __
-Mayhem P.. - Thur 01/21 - 11am - $4.00 - yes/no  -  - __
-Max and... - Tues 04/21 -  9am - $4.00 - yes/no  -  - __

A given show may have between 1 and 4 performances, and I figured the best
way to approach this was to consider each show time for each show as an
entity. There are 19 unique titles, but given different showtimes, it
becomes 38 'shows'.

I have the shows in an array ($shows), and the details for each show in its
own array (eg. $show_01) embedded into the show array.

I need to generate a row for each show (so 38 rows), and assign quantity and
total input fields a unique name and id.

I can't seem to get my foreach loops to work, will PHP parse embedded loops?

Here is an example of my embedded arrays:

[code=shows.php]

$shows = array();

 $shows['show_01'] = $show_01;
  $show_01 = array();
  $show_01['title'] = 'Van Cliburn Gold Medal Winner';
  $show_01['date'] = 'Tues. 10/13/2009';
  $show_01['time'] = '11am';
  $show_01['price'] = 4.00;
  $show_01['soldout'] = 0; //IF THE SHOW SELLS OUT, CHANGE "0" to "1"
(without quotations).

 $shows['show_02'] = $show_02;
  $show_02 = array();
  $show_02['title'] = 'Jack and the Beanstalk';
  $show_02['date'] = 'Fri. 10/23/2009';
  $show_02['time'] = '11am';
  $show_02['price'] = 4.00;
  $show_02['soldout'] = 0; //IF THE SHOW SELLS OUT, CHANGE "0" to "1"
(without quotations).

[/code]

And here are the foreach loops I'm trying to build the rows with:

[code=order.php]

 $value) {
 foreach ($value as $key2 => $value2) {
  print '  '. $value2 .'';
 }
 print '';
 print '  ';
 print '  $';
 print '';
 print '  yes/no';
 print '';
}
?>

[/code]

In case you were wondering why I embedded the foreach statement, I need each
array (eg. $show_22) to display in a row, and I need PHP to build as many
rows are there are shows.

Is this something I need to have in a database to work?

Thanks!


Re: [PHP] Embedded foreach loops

2009-08-10 Thread John Butler


On Aug 10, 2009, at 3:43 PM, Jim Lucas wrote:


Allen McCabe wrote:
I am creating an order form for tickets for a list of performances  
at a

performing arts center.

Currently, the form is on paper, and is set up as follows:
-Nutcracker - Tues 10/13 - 11am - $4.00



Thanks for letting us know about your new order form.

Did you have a question about something?  Or simply wanted to let us  
know?


Jim


I was thinking free tickets!




Re: [PHP] Embedding foreach loops

2009-08-10 Thread Jonathan Tapicer
On Mon, Aug 10, 2009 at 6:44 PM, Allen McCabe wrote:
> Gmail automatically sent my last email, apologies.
>
> I am creating an order form for tickets for a list of performances at a
> performing arts center.
>
> Currently, the form is on paper, and is set up as follows:
> -Title     - date  - time - price - soldout - quantity - total($)
> -Nutcracker - Tues 10/13 -  9am - $4.00 - yes/no  -  - __
> -Nutcracker - Tues 10/13 - 11am - $4.00 - yes/no  -  - __
> -Mayhem P.. - Thur 01/21 -  9am - $4.00 - yes/no  -  - __
> -Mayhem P.. - Thur 01/21 - 11am - $4.00 - yes/no  -  - __
> -Max and... - Tues 04/21 -  9am - $4.00 - yes/no  -  - __
>
> A given show may have between 1 and 4 performances, and I figured the best
> way to approach this was to consider each show time for each show as an
> entity. There are 19 unique titles, but given different showtimes, it
> becomes 38 'shows'.
>
> I have the shows in an array ($shows), and the details for each show in its
> own array (eg. $show_01) embedded into the show array.
>
> I need to generate a row for each show (so 38 rows), and assign quantity and
> total input fields a unique name and id.
>
> I can't seem to get my foreach loops to work, will PHP parse embedded loops?
>
> Here is an example of my embedded arrays:
>
> [code=shows.php]
>
> $shows = array();
>
>  $shows['show_01'] = $show_01;
>  $show_01 = array();
>  $show_01['title'] = 'Van Cliburn Gold Medal Winner';
>  $show_01['date'] = 'Tues. 10/13/2009';
>  $show_01['time'] = '11am';
>  $show_01['price'] = 4.00;
>  $show_01['soldout'] = 0; //IF THE SHOW SELLS OUT, CHANGE "0" to "1"
> (without quotations).
>
>  $shows['show_02'] = $show_02;
>  $show_02 = array();
>  $show_02['title'] = 'Jack and the Beanstalk';
>  $show_02['date'] = 'Fri. 10/23/2009';
>  $show_02['time'] = '11am';
>  $show_02['price'] = 4.00;
>  $show_02['soldout'] = 0; //IF THE SHOW SELLS OUT, CHANGE "0" to "1"
> (without quotations).
>
> [/code]
>
> And here are the foreach loops I'm trying to build the rows with:
>
> [code=order.php]
>
>  foreach ($shows as $key => $value) {
>  foreach ($value as $key2 => $value2) {
>      print '      '. $value2 .'';
>  }
>  print '';
>  print '       name="'.$value.'_qty"  type="text" id="'.$value.'_qty" size="5"  />';
>  print '      $';
>  print '         id="'.$value.'_total" size="15" maxlength="6"  />';
>  print '      yes/no';
>  print '';
> }
> ?>
>
> [/code]
>
> In case you were wondering why I embedded the foreach statement, I need each
> array (eg. $show_22) to display in a row, and I need PHP to build as many
> rows are there are shows.
>
> Is this something I need to have in a database to work?
>
> Thanks!
>

Embedded loops are OK, actually I don't know a language where you can't do it :)

I think that your problem is the $shows array creation, you do this:

> $shows = array();
>
>  $shows['show_01'] = $show_01;
>  $show_01 = array();

Note that you are assigning $show_01 to a key in $shows before
creating $show_01, you should first create and fill $show_01 and then
assign it to a key in $shows.

Hope that helps.

Jonathan

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



Re: [PHP] Embedding foreach loops

2009-08-10 Thread John Butler
I can't seem to get my foreach loops to work, will PHP parse  
embedded loops?


yes.


Is this something I need to have in a database to work?


no, you can do it with the arrays...  but it may be easier to work  
with over the long run if that data was in a db.


Anyway right after you finish creating the array and it's embedded  
arrays, in your code, then add this:
var_dump($shows); //--so you can see what you just created.  If it  
looks right, THEN go on bothering to try and parse it with your  
(embedded) foreach's {



John Butler (Govinda)
govinda.webdnat...@gmail.com




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



[PHP] how to say "inverse your value" (to a boolean)?

2009-08-10 Thread John Butler

quick Q:
I have this inside a foreach{}  that I want to alternate between on  
and off so I can alternate the background-color of my 's.


$tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter; //-boolean  
on and off


I am looking thru' docs and books, but can't remember (nor find now)  
in PHP how to say "inverse your value" (to a boolean).

?

TIA! -G


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



Re: [PHP] Embedding foreach loops

2009-08-10 Thread Allen McCabe
John,

I did this, and got my arrays dumped (on one line). After adding line
returns, here is a snippet:

[code=array dump]

array(38) {
["show_01"]=> array(5) {
["title"]=> string(29) "Van Cliburn Gold Medal Winner"
["date"]=> string(16) "Tues. 10/13/2009"
["time"]=> string(4) "11am"
["price"]=> float(4)
["soldout"]=> int(0)
}
["show_02"]=> array(5) {
["title"]=> string(22) "Jack and the Beanstalk"
["date"]=> string(15) "Fri. 10/23/2009"
["time"]=> string(4) "11am"
["price"]=> float(4)
["soldout"]=> int(0)
}

[/code]

and for reference, my original php used to set up arrays

[code=shows.php]

$shows = array();
  $show_01 = array();
  $show_01['title'] = 'Van Cliburn Gold Medal Winner';
  $show_01['date'] = 'Tues. 10/13/2009';
  $show_01['time'] = '11am';
  $show_01['price'] = 4.00;
  $show_01['soldout'] = 0; //IF THE SHOW SELLS OUT, CHANGE "0" to "1"
(without quotations).
 $shows['show_01'] = $show_01;
  $show_02 = array();
  $show_02['title'] = 'Jack and the Beanstalk';
  $show_02['date'] = 'Fri. 10/23/2009';
  $show_02['time'] = '11am';
  $show_02['price'] = 4.00;
  $show_02['soldout'] = 0; //IF THE SHOW SELLS OUT, CHANGE "0" to "1"
(without quotations).
 $shows['show_02'] = $show_02;

[/code]

Does this dump look right?

On Mon, Aug 10, 2009 at 3:04 PM, John Butler
wrote:

>  I can't seem to get my foreach loops to work, will PHP parse embedded
>> loops?
>>
>
> yes.
>
> Is this something I need to have in a database to work?
>>
>
> no, you can do it with the arrays...  but it may be easier to work with
> over the long run if that data was in a db.
>
> Anyway right after you finish creating the array and it's embedded arrays,
> in your code, then add this:
> var_dump($shows); //--so you can see what you just created.  If it looks
> right, THEN go on bothering to try and parse it with your (embedded)
> foreach's {
>
> 
> John Butler (Govinda)
> govinda.webdnat...@gmail.com
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] Re: how to say "inverse your value" (to a boolean)?

2009-08-10 Thread Tony Marston
Try $tableRowBGcolorBoolCounter = !$tableRowBGcolorBoolCounter

Notice that it says '= !' instead of !='.
-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

"John Butler"  wrote in message 
news:52842d6f-dd45-44a6-ae06-2e58ef8f6...@gmail.com...
> quick Q:
> I have this inside a foreach{}  that I want to alternate between on  and 
> off so I can alternate the background-color of my 's.
>
> $tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter; //-boolean  on 
> and off
>
> I am looking thru' docs and books, but can't remember (nor find now)  in 
> PHP how to say "inverse your value" (to a boolean).
> ?
>
> TIA! -G
> 



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



Re: [PHP] how to say "inverse your value" (to a boolean)?

2009-08-10 Thread Martin Scotta
You can do this...

for( $b=true; ; $b = !$b )
{

}

I usually use this solution

$types = array( 'one', 'two' );
foreach( $list as $item ) # <-- your set of (many) items
{
echo current( $types ); # <-- this prints the current class
# code
next( $types ) or reset( $types ); # and this do the magic
}

Hey! look, this solution can work with more than 2 types...
try it with many types: $types = array( 'one', 'two', three', 'four' );

On Mon, Aug 10, 2009 at 7:16 PM, John Butler
wrote:

> quick Q:
> I have this inside a foreach{}  that I want to alternate between on and off
> so I can alternate the background-color of my 's.
>
> $tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter; //-boolean on
> and off
>
> I am looking thru' docs and books, but can't remember (nor find now) in PHP
> how to say "inverse your value" (to a boolean).
> ?
>
> TIA! -G
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Martin Scotta


Re: [PHP] Embedding foreach loops

2009-08-10 Thread John Butler


I did this, and got my arrays dumped (on one line). After adding  
line returns, here is a snippet:



it looks OK.  Note that you can see (copy/paste) that array which you  
just dumped, much better, if you view the source code of the html  
page.  OR you can use  to make that format persist thru' to what  
you see without viewing the source., Like so:


echo "\n";
var_dump($theArray);
echo "\n";
echo "\n";

My brain is so full of my own work..  and I am newbie compared to most  
lurking here.. but I am sure we'll figure out your issue if we work on  
it systematically.  OK, your OP just said, "..I can't seem to get my  
foreach loops to work.."  , but you never said exactly what is the  
problem.  Break the problem down to the smallest thing that you can  
find that is not behaving as you expect it to, and explain  THAT to  
me.  We'll do this step by step.


-John

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



Re: [PHP] Embedding foreach loops

2009-08-10 Thread Martin Scotta
There are a lot of alternatives if you want to remove the arrays XML,
ini files, text files, yaml, json
Of course... they all will implicate to open the file, read it, and then
process it.

On Mon, Aug 10, 2009 at 7:29 PM, Allen McCabe  wrote:

> John,
>
> I did this, and got my arrays dumped (on one line). After adding line
> returns, here is a snippet:
>
> [code=array dump]
>
> array(38) {
> ["show_01"]=> array(5) {
> ["title"]=> string(29) "Van Cliburn Gold Medal Winner"
> ["date"]=> string(16) "Tues. 10/13/2009"
> ["time"]=> string(4) "11am"
> ["price"]=> float(4)
> ["soldout"]=> int(0)
> }
> ["show_02"]=> array(5) {
> ["title"]=> string(22) "Jack and the Beanstalk"
> ["date"]=> string(15) "Fri. 10/23/2009"
> ["time"]=> string(4) "11am"
> ["price"]=> float(4)
> ["soldout"]=> int(0)
> }
>
> [/code]
>
> and for reference, my original php used to set up arrays
>
> [code=shows.php]
>
> $shows = array();
>   $show_01 = array();
>  $show_01['title'] = 'Van Cliburn Gold Medal Winner';
>  $show_01['date'] = 'Tues. 10/13/2009';
>  $show_01['time'] = '11am';
>  $show_01['price'] = 4.00;
>  $show_01['soldout'] = 0; //IF THE SHOW SELLS OUT, CHANGE "0" to "1"
> (without quotations).
>  $shows['show_01'] = $show_01;
>   $show_02 = array();
>  $show_02['title'] = 'Jack and the Beanstalk';
>  $show_02['date'] = 'Fri. 10/23/2009';
>  $show_02['time'] = '11am';
>  $show_02['price'] = 4.00;
>  $show_02['soldout'] = 0; //IF THE SHOW SELLS OUT, CHANGE "0" to "1"
> (without quotations).
>  $shows['show_02'] = $show_02;
>
> [/code]
>
> Does this dump look right?
>
> On Mon, Aug 10, 2009 at 3:04 PM, John Butler
> wrote:
>
> >  I can't seem to get my foreach loops to work, will PHP parse embedded
> >> loops?
> >>
> >
> > yes.
> >
> > Is this something I need to have in a database to work?
> >>
> >
> > no, you can do it with the arrays...  but it may be easier to work with
> > over the long run if that data was in a db.
> >
> > Anyway right after you finish creating the array and it's embedded
> arrays,
> > in your code, then add this:
> > var_dump($shows); //--so you can see what you just created.  If it looks
> > right, THEN go on bothering to try and parse it with your (embedded)
> > foreach's {
> >
> > 
> > John Butler (Govinda)
> > govinda.webdnat...@gmail.com
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>



-- 
Martin Scotta


Re: [PHP] Re: how to say "inverse your value" (to a boolean)?

2009-08-10 Thread John Butler

= !


!

=)

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



[PHP] Re: how to say "inverse your value" (to a boolean)?

2009-08-10 Thread Ralph Deffke
with XOR

try this
$a = 0;
echo $a ^ 1;
$a = 1;
echo $a ^ 1;

hope that helps

ralph
ralph_def...@yahoo.de

"John Butler"  wrote in message
news:52842d6f-dd45-44a6-ae06-2e58ef8f6...@gmail.com...
> quick Q:
> I have this inside a foreach{}  that I want to alternate between on
> and off so I can alternate the background-color of my 's.
>
> $tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter; //-boolean
> on and off
>
> I am looking thru' docs and books, but can't remember (nor find now)
> in PHP how to say "inverse your value" (to a boolean).
> ?
>
> TIA! -G
>



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



RE: [PHP] APC optimization in CLI

2009-08-10 Thread Daevid Vincent
> From: Robert Cummings [mailto:rob...@interjinn.com] 
>
> However, accelerators don't make scripts faster per se. 
> They merely cut out the script reading and parsing time. 

Which is a HUGE portion of time since PHP is a two-pass step. One that reads
and compiles to opcodes (with syntax checking) and another which actually
executes it.

> So, while 
> you may experience 10% gain within the first second of your script 
> running, the use of an accelerator should have no bearing 
> down the road 
> except for the initial dynamic load of other scripts at runtime.

This is sort of misleading.

You will experience faster page loads if it's a web php file, and if APC
does allow you to run cached scripts via CLI, then these scripts will start
execution immediately too.

> Long running scripts will see almost no benefit from an accelerator. 

PHP scripts are (like it or not) NOT designed to be daemons and run for long
periods of time. The GC is no optimized for such things. It's quite
inneficient from what I've read. The whole purpose of a PHP _page_ is to get
in and get out. Hit it and quit it. Therefore memory efficiency is not as
important as speed and ease of use.

> This is the general reason why CLI acceleration isn't very useful. That
said 
> though, one could certainly glean an advantage if they had a 
> cron job or other daemon that was loading a script often.

As is probably often the case, moreso than a "long running script".

I think a code optimizer is what would be desired if you're trying to make a
faster script. However in this day and age, I suspect that the 2nd phase of
the compiler already does all the optimizing it can before creating the byte
code. 


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



Re: [PHP] how to say "inverse your value" (to a boolean)?

2009-08-10 Thread Jim Lucas
John Butler wrote:
> quick Q:
> I have this inside a foreach{}  that I want to alternate between on and
> off so I can alternate the background-color of my 's.
> 
> $tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter; //-boolean
> on and off
> 
> I am looking thru' docs and books, but can't remember (nor find now) in
> PHP how to say "inverse your value" (to a boolean).
> ?
> 
> TIA! -G
> 
> 




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



Re: [PHP] Embedding foreach loops

2009-08-10 Thread Allen McCabe
I am using the print function to display my html. I cannot get the line
return ( \n ) character to actually push the html onto the next line, it
just gets displayed instead. Should I be using echo?



On Mon, Aug 10, 2009 at 3:41 PM, John Butler
wrote:

>
> I did this, and got my arrays dumped (on one line). After adding line
>> returns, here is a snippet:
>>
>
>
> it looks OK.  Note that you can see (copy/paste) that array which you just
> dumped, much better, if you view the source code of the html page.  OR you
> can use  to make that format persist thru' to what you see without
> viewing the source., Like so:
>
>echo "\n";
>var_dump($theArray);
>echo "\n";
>echo "\n";
>
> My brain is so full of my own work..  and I am newbie compared to most
> lurking here.. but I am sure we'll figure out your issue if we work on it
> systematically.  OK, your OP just said, "..I can't seem to get my foreach
> loops to work.."  , but you never said exactly what is the problem.  Break
> the problem down to the smallest thing that you can find that is not
> behaving as you expect it to, and explain  THAT to me.  We'll do this step
> by step.
>
> -John
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Embedding foreach loops

2009-08-10 Thread Ben Dunlap
> $shows = array();
>  $show_01 = array();
>  $show_01['title'] = 'Van Cliburn Gold Medal Winner';
>  $show_01['date'] = 'Tues. 10/13/2009';
>  $show_01['time'] = '11am';
>  $show_01['price'] = 4.00;
>  $show_01['soldout'] = 0; //IF THE SHOW SELLS OUT, CHANGE "0" to "1"
> (without quotations).
>  $shows['show_01'] = $show_01;
[etc.]

If I'm setting up a lot of static data ahead of time like this, I
prefer a slightly simpler syntax (or at least it seems simpler to me):

$shows = array(
'show_01' => array(
'title' => 'Van Cliburn Gold Medal Winner',
'date' => [etc.]
),
'show_02' => array(
'title' => [etc.]
),
[etc.]
);

And sure, you could do all this in a database, or some other sort of
external storage, but unless you're looking at creating a separate UI
for someone other than yourself to input the data, it's probably
simpler all around just to define the data directly in PHP. No reason
you couldn't upgrade to something more sophisticated down the road, if
the customer requires it.

Ben

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



RE: [PHP] Embedding foreach loops

2009-08-10 Thread Daevid Vincent
You're not using the  and  tag most likely then. 

> -Original Message-
> From: Allen McCabe [mailto:allenmcc...@gmail.com] 
> Sent: Monday, August 10, 2009 4:11 PM
> To: John Butler
> Cc: phpList
> Subject: Re: [PHP] Embedding foreach loops
> 
> I am using the print function to display my html. I cannot 
> get the line
> return ( \n ) character to actually push the html onto the 
> next line, it
> just gets displayed instead. Should I be using echo?
> 
> 
> 
> On Mon, Aug 10, 2009 at 3:41 PM, John Butler
> wrote:
> 
> >
> > I did this, and got my arrays dumped (on one line). After 
> adding line
> >> returns, here is a snippet:
> >>
> >
> >
> > it looks OK.  Note that you can see (copy/paste) that array 
> which you just
> > dumped, much better, if you view the source code of the 
> html page.  OR you
> > can use  to make that format persist thru' to what you 
> see without
> > viewing the source., Like so:
> >
> >echo "\n";
> >var_dump($theArray);
> >echo "\n";
> >echo "\n";
> >
> > My brain is so full of my own work..  and I am newbie 
> compared to most
> > lurking here.. but I am sure we'll figure out your issue if 
> we work on it
> > systematically.  OK, your OP just said, "..I can't seem to 
> get my foreach
> > loops to work.."  , but you never said exactly what is the 
> problem.  Break
> > the problem down to the smallest thing that you can find that is not
> > behaving as you expect it to, and explain  THAT to me.  
> We'll do this step
> > by step.
> >
> > -John
> >
> >
> > --
> > 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] how to say "inverse your value" (to a boolean)?

2009-08-10 Thread Daevid Vincent
NO! For the love of God and all that is holy, don't do that accumulator /
mod "hack". 
That's so 1980's. And why make the CPU do all that math for every row...

Just do this. It's quick and simple:

CSS:
.dataRow1 { background-color: #DFDFDF; }
.dataRow2 { background-color: #FF; }

foreach ($foo_array as $foo) {
   ?>"> -Original Message-
> From: Jim Lucas [mailto:li...@cmsws.com] 
> Sent: Monday, August 10, 2009 4:03 PM
> To: John Butler
> Cc: PHP-General List
> Subject: Re: [PHP] how to say "inverse your value" (to a boolean)?
> 
> John Butler wrote:
> > quick Q:
> > I have this inside a foreach{}  that I want to alternate 
> between on and
> > off so I can alternate the background-color of my 's.
> > 
> > $tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter; 
> //-boolean
> > on and off
> > 
> > I am looking thru' docs and books, but can't remember (nor 
> find now) in
> > PHP how to say "inverse your value" (to a boolean).
> > ?
> > 
> > TIA! -G
> > 
> > 
> 
>  
> $arr = range(1, 10);
> 
> $i = 0;
> foreach ( $arr AS $row ) {
> 
>   $row_color = ( ( $i++ % 2 ) ? 'green' : 'red');
> 
>   echo $row_color;
> 
> }
> 
> ?>
> 
> 
> -- 
> 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] Embedding foreach loops

2009-08-10 Thread Ben Dunlap
> I am using the print function to display my html. I cannot get the line
> return ( \n ) character to actually push the html onto the next line, it
> just gets displayed instead. Should I be using echo?

In the PHP code snippet you pasted above, you're using single-quotes
to delimit your literal strings. In-between single-quotes, '\n' is not
converted to a newline character. It's interpeted completely
literally:

http://us.php.net/manual/en/language.types.string.php#language.types.string.syntax.single

Also, are you looking to insert a line break into the HTML itself --
just to keep your HTML code clean -- or into the visible page that's
rendered from the HTML? Because newlines don't have any significance
in HTML. You'd need to insert a  or close a block-level element
to get the effect of a line-break in the visible page.

Ben

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



Re: [PHP] APC optimization in CLI

2009-08-10 Thread Nathan Nobbe
On Mon, Aug 10, 2009 at 4:58 PM, Daevid Vincent  wrote:

> > From: Robert Cummings [mailto:rob...@interjinn.com]
> >
> > However, accelerators don't make scripts faster per se.
> > They merely cut out the script reading and parsing time.
>
> Which is a HUGE portion of time since PHP is a two-pass step. One that
> reads
> and compiles to opcodes (with syntax checking) and another which actually
> executes it.


obviously, this is sensitive to the amount of code being run in a single
request.  the more code, the more parsing / compile time.  but even that has
no bearing on how long the code of the script will run (as rob said).  if
youre dependent on remote resources, eg a database or other network
requests, like soap or rest to other remote servers, those are the sorts of
things that generally dominate the time spent handling a request.  even for
scripts run through the webserver, an opcode cache is a secondary
performance booster, where optimizing things like database performance will
usually drawf the returns a site gets from apc.  that being said, you
obviously want all the juice you can get, so running apc aside a tuned
database is ideal :)


>
>
> > So, while
> > you may experience 10% gain within the first second of your script
> > running, the use of an accelerator should have no bearing
> > down the road
> > except for the initial dynamic load of other scripts at runtime.
>
> This is sort of misleading.
>
> You will experience faster page loads if it's a web php file, and if APC
> does allow you to run cached scripts via CLI, then these scripts will start
> execution immediately too.


right, but from what ive seen the php environment is not persistent on the
cli like it is inside a webserver.  therefore, when the second request comes
in, apc will have to re-cache all of the scripts it cached the first time.
 afiak anyway.  if there is persistence in cli php, then how would one clear
out the cache for the cli based scripts??  apc gives you no tools to
accomplish this that im aware of, and theres no way you could do it from a
webserver either, since im pretty sure, cached scripts, just like apc 'user'
variables are only visible w/in a single domain (def correct me on that part
if im off base, i know eaccelerator handles things that way)


>
>
> > Long running scripts will see almost no benefit from an accelerator.
>
> PHP scripts are (like it or not) NOT designed to be daemons and run for
> long
> periods of time.


def not inside of the webserver, but on the cli i see no reason why php cant
be long running - and good at it.  you just have to like actually start
cleaning up old variables, lol.  so while its not as forgiving as the
webserver php environment, i doubt there are any real reasons to stay away
from a long running php cli app except performance vs. alternatives.


> The GC is no optimized for such things. It's quite
> inneficient from what I've read. The whole purpose of a PHP _page_ is to
> get
> in and get out. Hit it and quit it. Therefore memory efficiency is not as
> important as speed and ease of use.
>
> > This is the general reason why CLI acceleration isn't very useful. That
> said
> > though, one could certainly glean an advantage if they had a
> > cron job or other daemon that was loading a script often.
>
> As is probably often the case, moreso than a "long running script".
>
> I think a code optimizer is what would be desired if you're trying to make
> a
> faster script. However in this day and age, I suspect that the 2nd phase of
> the compiler already does all the optimizing it can before creating the
> byte
> code.


im guessing the optimization inside of apc is currently pretty weak, since
eacellerator has been the system most popular for optimization thus far, and
since apc is adding optimization as a future component of the project,
officially, which is still in alpha.

http://pecl.php.net/package-info.php?package=optimizer&version=0.1alpha1

-nathan


[PHP] Re: MySQL auto_increment fields Server version: 5.1.32-community-log

2009-08-10 Thread Ollisso
On Sun, 09 Aug 2009 21:17:15 +0300, "Ralph Deffke"   
wrote:



Hi all,

I'm facing the fact that it seems that auto_increment fields in a table  
not
start at 1 like it was in earlier versions even if I install mySQL brand  
new

creating all tables new. it seems to me that auto_increments handling has
changed to older version. is somebody out there who can give me a quick
background about auto_increment and how and if I can control the  
behavior of

mySQL about them.

ralph_def...@yahoo.de



try:
ALTER TABLE xxx AUTO_INCREMENT=1;



--

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



Re: [PHP] Embedding foreach loops

2009-08-10 Thread John Butler
I am using the print function to display my html. I cannot get the  
line return ( \n ) character to actually push the html onto the next  
line, it just gets displayed instead. Should I be using echo?



Allen, you off and running again?

echo "blah..  \n"; //<-- this will print  the literal 'blah..  '  and  
then a newline into your HTML *source code*
echo 'blah..  \n'; //<-- this will print the literal 'blah..  \n' into  
your HTML *source code*


IIRC print is the same as echo.  That is not your apparent issue.

Say if you are stuck again, and on what exactly.

-John

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



Re: [PHP] how to say "inverse your value" (to a boolean)?

2009-08-10 Thread Martin Scotta
Use...

$dr = !$dr

if you want

Notice: Undefined variable: dr

All variables MUST be initialized before using.
If you PHP does not complains about it you should read about error_reporting

On Mon, Aug 10, 2009 at 8:18 PM, Daevid Vincent  wrote:

> NO! For the love of God and all that is holy, don't do that accumulator /
> mod "hack".
> That's so 1980's. And why make the CPU do all that math for every
> row...
>
> Just do this. It's quick and simple:
>
> CSS:
>.dataRow1 { background-color: #DFDFDF; }
>.dataRow2 { background-color: #FF; }
>
> foreach ($foo_array as $foo) {
>   ?>"> ?> }
>
> No need to initialize $dr as by default PHP will make it a boolean "false",
> then each itteration, it will toggle true/false and substitute the CSS
> class
>
> > -Original Message-
> > From: Jim Lucas [mailto:li...@cmsws.com]
> > Sent: Monday, August 10, 2009 4:03 PM
> > To: John Butler
> > Cc: PHP-General List
> > Subject: Re: [PHP] how to say "inverse your value" (to a boolean)?
> >
> > John Butler wrote:
> > > quick Q:
> > > I have this inside a foreach{}  that I want to alternate
> > between on and
> > > off so I can alternate the background-color of my 's.
> > >
> > > $tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter;
> > //-boolean
> > > on and off
> > >
> > > I am looking thru' docs and books, but can't remember (nor
> > find now) in
> > > PHP how to say "inverse your value" (to a boolean).
> > > ?
> > >
> > > TIA! -G
> > >
> > >
> >
> >  >
> > $arr = range(1, 10);
> >
> > $i = 0;
> > foreach ( $arr AS $row ) {
> >
> >   $row_color = ( ( $i++ % 2 ) ? 'green' : 'red');
> >
> >   echo $row_color;
> >
> > }
> >
> > ?>
> >
> >
> > --
> > 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
>
>


-- 
Martin Scotta


[PHP] Re: how to say "inverse your value" (to a boolean)?

2009-08-10 Thread Ralph Deffke
u...
try
echo "";
for( $i=0 ; $i<10; $i++){
  echo "something " . (($a = $a^1) ? "red\n" : "green\n");
}
echo "";

watchout the brackets !

cheers
ralph_def...@yahoo.de

"John Butler"  wrote in message
news:52842d6f-dd45-44a6-ae06-2e58ef8f6...@gmail.com...
> quick Q:
> I have this inside a foreach{}  that I want to alternate between on
> and off so I can alternate the background-color of my 's.
>
> $tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter; //-boolean
> on and off
>
> I am looking thru' docs and books, but can't remember (nor find now)
> in PHP how to say "inverse your value" (to a boolean).
> ?
>
> TIA! -G
>



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



RE: [PHP] how to say "inverse your value" (to a boolean)?

2009-08-10 Thread Daevid Vincent
Then YOU have more aggressive error_reporting than the default setting
turned on. You might consider turning it down a notch. NOTICEs are basically
useless and bloat your code IMHO -- and apparently the PHP devs too as per
this...

http://us2.php.net/manual/en/function.error-reporting.php

// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);

Don't tell me what to do! You're not my father! ;-)

http://daevid.com

"Some people, when confronted with a problem, think 'I know, I'll use XML.'"
Now they have two problems. 

> -Original Message-
> From: Martin Scotta [mailto:martinsco...@gmail.com] 
> Sent: Monday, August 10, 2009 5:39 PM
> To: Daevid Vincent
> Cc: PHP-General List
> Subject: Re: [PHP] how to say "inverse your value" (to a boolean)?
> 
> Use...
> 
> $dr = !$dr
> 
> if you want
> 
> Notice: Undefined variable: dr
> 
> All variables MUST be initialized before using.
> If you PHP does not complains about it you should read about 
> error_reporting
> 
> On Mon, Aug 10, 2009 at 8:18 PM, Daevid Vincent 
>  wrote:
> 
> > NO! For the love of God and all that is holy, don't do that 
> accumulator /
> > mod "hack".
> > That's so 1980's. And why make the CPU do all that math 
> for every
> > row...
> >
> > Just do this. It's quick and simple:
> >
> > CSS:
> >.dataRow1 { background-color: #DFDFDF; }
> >.dataRow2 { background-color: #FF; }
> >
> > foreach ($foo_array as $foo) {
> >   ?> ?>"> > ?> > }
> >
> > No need to initialize $dr as by default PHP will make it a 
> boolean "false",
> > then each itteration, it will toggle true/false and 
> substitute the CSS
> > class
> >
> > > -Original Message-
> > > From: Jim Lucas [mailto:li...@cmsws.com]
> > > Sent: Monday, August 10, 2009 4:03 PM
> > > To: John Butler
> > > Cc: PHP-General List
> > > Subject: Re: [PHP] how to say "inverse your value" (to a boolean)?
> > >
> > > John Butler wrote:
> > > > quick Q:
> > > > I have this inside a foreach{}  that I want to alternate
> > > between on and
> > > > off so I can alternate the background-color of my 's.
> > > >
> > > > $tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter;
> > > //-boolean
> > > > on and off
> > > >
> > > > I am looking thru' docs and books, but can't remember (nor
> > > find now) in
> > > > PHP how to say "inverse your value" (to a boolean).
> > > > ?
> > > >
> > > > TIA! -G
> > > >
> > > >
> > >
> > >  > >
> > > $arr = range(1, 10);
> > >
> > > $i = 0;
> > > foreach ( $arr AS $row ) {
> > >
> > >   $row_color = ( ( $i++ % 2 ) ? 'green' : 'red');
> > >
> > >   echo $row_color;
> > >
> > > }
> > >
> > > ?>
> > >
> > >
> > > --
> > > 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
> >
> >
> 
> 
> -- 
> Martin Scotta
> 


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



Re: [PHP] Re: how to say "inverse your value" (to a boolean)?

2009-08-10 Thread John Butler

 echo "something " . (($a = $a^1) ? "red\n" : "green\n");


Re: The "?" char in this  line above..
where in the php docs can I read about what that is doing?
I have not come across this construct before today, from you guys.

thanks
-John

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



Re: [PHP] Re: how to say "inverse your value" (to a boolean)?

2009-08-10 Thread Adam Randall
http://us3.php.net/manual/en/language.operators.comparison.php

Find "Ternary" on that page.

It's a shortened conditional:

cond ? true : false

Adam.

On Mon, Aug 10, 2009 at 6:27 PM, John
Butler wrote:
>>  echo "something " . (($a = $a^1) ? "red\n" : "green\n");
>
> Re: The "?" char in this  line above..
> where in the php docs can I read about what that is doing?
> I have not come across this construct before today, from you guys.
>
> thanks
> -John
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
Adam Randall
http://www.xaren.net
AIM: blitz574

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



[PHP] Sending email w/ attachments

2009-08-10 Thread Skip Evans

Hey all,

Trying to send emails with attachments, first try at this. And 
am trying to adapt sample code I found here:


http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php

Trying this:

($data contains the contents of the file; I've verified this)

$hash = md5(date('r', time()));
$attachment = chunk_split(base64_encode($data));
$body_attachment = "--PHP-mixed-$hash--\n" .
"Content-Type: application/octet-stream; name=\"$filename\"\r\n" .
"Content-Transfer-Encoding: base64\n" .
"Content-Disposition: attachment\n".
$attachment . "\n" .
"--PHP-mixed-$hash--\n";

I then append $attachment this to the end of the email body 
and send it on. I've verified it is reading the file properly, 
in this test case it is a place text file. But I've tried a 
PDF and that did not work as well.


What happens is the email comes through and shows an 
attachment paper clip icon in Thunderbird, but when the email 
is clicked on the icon disappears and the email is empty, even 
the body is not there and no attachment either.


A final question I have is does the content-type value need to 
change for text files, Word Docs, PDFs, Excel files, etc, or 
is there one type that can handle any file type?


Any help would be great. I'm rather stuck and floundering here.

Thanks,
Skip

--

Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com

Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

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



Re: [PHP] Sending email w/ attachments

2009-08-10 Thread Bastien Koert
On Mon, Aug 10, 2009 at 9:49 PM, Skip Evans wrote:
> Hey all,
>
> Trying to send emails with attachments, first try at this. And am trying to
> adapt sample code I found here:
>
> http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php
>
> Trying this:
>
> ($data contains the contents of the file; I've verified this)
>
> $hash = md5(date('r', time()));
> $attachment = chunk_split(base64_encode($data));
> $body_attachment = "--PHP-mixed-$hash--\n" .
> "Content-Type: application/octet-stream; name=\"$filename\"\r\n" .
> "Content-Transfer-Encoding: base64\n" .
> "Content-Disposition: attachment\n".
> $attachment . "\n" .
> "--PHP-mixed-$hash--\n";
>
> I then append $attachment this to the end of the email body and send it on.
> I've verified it is reading the file properly, in this test case it is a
> place text file. But I've tried a PDF and that did not work as well.
>
> What happens is the email comes through and shows an attachment paper clip
> icon in Thunderbird, but when the email is clicked on the icon disappears
> and the email is empty, even the body is not there and no attachment either.
>
> A final question I have is does the content-type value need to change for
> text files, Word Docs, PDFs, Excel files, etc, or is there one type that can
> handle any file type?
>
> Any help would be great. I'm rather stuck and floundering here.
>
> Thanks,
> Skip
>
> --
> 
> Skip Evans
> Big Sky Penguin, LLC
> 503 S Baldwin St, #1
> Madison WI 53703
> 608.250.2720
> http://bigskypenguin.com
> 
> Those of you who believe in
> telekinesis, raise my hand.
>  -- Kurt Vonnegut
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Use PHPMailer or one of the other classes available...makes life
so much easier

-- 

Bastien

Cat, the other other white meat

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



RE: [PHP] Re: how to say "inverse your value" (to a boolean)?

2009-08-10 Thread Daevid Vincent
Pretty much the best operator ever invented IMHO. And Since PHP 5.3, it is
possible to leave out the middle part of the ternary operator. Expression
expr1 ?: expr3 returns expr1 if expr1  evaluates to TRUE, and expr3
otherwise. Awesome!

Also, Adam Randall set up us the bomb. ;-)
(http://www.youtube.com/watch?v=qItugh-fFgg)

> -Original Message-
> From: Adam Randall [mailto:randa...@gmail.com] 
> Sent: Monday, August 10, 2009 6:41 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Re: how to say "inverse your value" (to a boolean)?
> 
> http://us3.php.net/manual/en/language.operators.comparison.php
> 
> Find "Ternary" on that page.
> 
> It's a shortened conditional:
> 
> cond ? true : false
> 
> Adam.
> 
> On Mon, Aug 10, 2009 at 6:27 PM, John
> Butler wrote:
> >>  echo "something " . (($a = $a^1) ? "red\n" : "green\n");
> >
> > Re: The "?" char in this  line above..
> > where in the php docs can I read about what that is doing?
> > I have not come across this construct before today, from you guys.
> >
> > thanks
> > -John
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> 
> 
> -- 
> Adam Randall
> http://www.xaren.net
> AIM: blitz574
> 
> -- 
> 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] Re: how to say "inverse your value" (to a boolean)?

2009-08-10 Thread Adam Randall
No...not zerowing...no...

But yes, the ternary operator is the bomb, which you can get carried
away with. Daevid knows what I mean :)

Adam.

On Mon, Aug 10, 2009 at 6:59 PM, Daevid Vincent wrote:
> Pretty much the best operator ever invented IMHO. And Since PHP 5.3, it is
> possible to leave out the middle part of the ternary operator. Expression
> expr1 ?: expr3 returns expr1 if expr1  evaluates to TRUE, and expr3
> otherwise. Awesome!
>
> Also, Adam Randall set up us the bomb. ;-)
> (http://www.youtube.com/watch?v=qItugh-fFgg)
>
>> -Original Message-
>> From: Adam Randall [mailto:randa...@gmail.com]
>> Sent: Monday, August 10, 2009 6:41 PM
>> To: php-general@lists.php.net
>> Subject: Re: [PHP] Re: how to say "inverse your value" (to a boolean)?
>>
>> http://us3.php.net/manual/en/language.operators.comparison.php
>>
>> Find "Ternary" on that page.
>>
>> It's a shortened conditional:
>>
>> cond ? true : false
>>
>> Adam.
>>
>> On Mon, Aug 10, 2009 at 6:27 PM, John
>> Butler wrote:
>> >>  echo "something " . (($a = $a^1) ? "red\n" : "green\n");
>> >
>> > Re: The "?" char in this  line above..
>> > where in the php docs can I read about what that is doing?
>> > I have not come across this construct before today, from you guys.
>> >
>> > thanks
>> > -John
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>>
>>
>>
>> --
>> Adam Randall
>> http://www.xaren.net
>> AIM: blitz574
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>



-- 
Adam Randall
http://www.xaren.net
AIM: blitz574

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



Re: [PHP] Sending email w/ attachments

2009-08-10 Thread Adam Randall
Funny, I just had to figure out today how to nicely do HTML e-mails. I
ended up using PEAR:Mail_mime, and it worked pretty well. It will also
work for your attachments. I believe that PHP itself recommends it on
their mail() function reference page.

Adam.

On Mon, Aug 10, 2009 at 6:49 PM, Skip Evans wrote:
> Hey all,
>
> Trying to send emails with attachments, first try at this. And am trying to
> adapt sample code I found here:
>
> http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php
>
> Trying this:
>
> ($data contains the contents of the file; I've verified this)
>
> $hash = md5(date('r', time()));
> $attachment = chunk_split(base64_encode($data));
> $body_attachment = "--PHP-mixed-$hash--\n" .
> "Content-Type: application/octet-stream; name=\"$filename\"\r\n" .
> "Content-Transfer-Encoding: base64\n" .
> "Content-Disposition: attachment\n".
> $attachment . "\n" .
> "--PHP-mixed-$hash--\n";
>
> I then append $attachment this to the end of the email body and send it on.
> I've verified it is reading the file properly, in this test case it is a
> place text file. But I've tried a PDF and that did not work as well.
>
> What happens is the email comes through and shows an attachment paper clip
> icon in Thunderbird, but when the email is clicked on the icon disappears
> and the email is empty, even the body is not there and no attachment either.
>
> A final question I have is does the content-type value need to change for
> text files, Word Docs, PDFs, Excel files, etc, or is there one type that can
> handle any file type?
>
> Any help would be great. I'm rather stuck and floundering here.
>
> Thanks,
> Skip
>
> --
> 
> Skip Evans
> Big Sky Penguin, LLC
> 503 S Baldwin St, #1
> Madison WI 53703
> 608.250.2720
> http://bigskypenguin.com
> 
> Those of you who believe in
> telekinesis, raise my hand.
>  -- Kurt Vonnegut
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
Adam Randall
http://www.xaren.net
AIM: blitz574

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



Re: [PHP] how to say "inverse your value" (to a boolean)?

2009-08-10 Thread Paul M Foster
On Mon, Aug 10, 2009 at 04:18:29PM -0700, Daevid Vincent wrote:

> NO! For the love of God and all that is holy, don't do that accumulator /
> mod "hack".
> That's so 1980's. And why make the CPU do all that math for every row...
> 
> Just do this. It's quick and simple:
> 
> CSS:
>   .dataRow1 { background-color: #DFDFDF; }
>   .dataRow2 { background-color: #FF; }
> 
> foreach ($foo_array as $foo) {
>?>"> ?> }


NO! For the love of God and all that is holy, don't do that ">

(I just couldn't resist! ;-)

Paul

-- 
Paul M. Foster

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



Re: [PHP] Sending email w/ attachments

2009-08-10 Thread Skip Evans

Bastien Koert wrote:


Use PHPMailer or one of the other classes available...makes life
so much easier




Kick Ass!!!


Yes! Wow! Was that a breeze! That class rocks!

Thanks tons, Bastien!

I have to admit when I first saw your reply I thought, "Oh, 
man, another class to learn? But I know this is so close to 
working."


I look at the sample and thought, "This looks easy," and had 
it working in no time.


Big thanks again!

Attachments were a big deal here and this makes it a breeze, 
AND it looks like multiple attachments would be no problem?


Very cool!

Skip

--

Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com

Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

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



Re: [PHP] how to say "inverse your value" (to a boolean)?

2009-08-10 Thread Jim Lucas

Daevid Vincent wrote:

NO! For the love of God and all that is holy, don't do that accumulator /
mod "hack". 
That's so 1980's. And why make the CPU do all that math for every row...


Just do this. It's quick and simple:

CSS:
.dataRow1 { background-color: #DFDFDF; }
.dataRow2 { background-color: #FF; }

foreach ($foo_array as $foo) {
   ?>">

Wow, were to start with all the problems in the above code:
1.  Short tags?
2.  Not using echo or print.  You actually recommend breaking in/out of php?
3.  Using uninitialized variables (I run with the E_ALL crowd)
4.  Using the  and not the ...  Hmmm


}

No need to initialize $dr as by default PHP will make it a boolean "false",
then each itteration, it will toggle true/false and substitute the CSS class


-Original Message-
From: Jim Lucas [mailto:li...@cmsws.com] 
Sent: Monday, August 10, 2009 4:03 PM

To: John Butler
Cc: PHP-General List
Subject: Re: [PHP] how to say "inverse your value" (to a boolean)?

John Butler wrote:

quick Q:
I have this inside a foreach{}  that I want to alternate 

between on and

off so I can alternate the background-color of my 's.

$tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter; 

//-boolean

on and off

I am looking thru' docs and books, but can't remember (nor 

find now) in

PHP how to say "inverse your value" (to a boolean).
?

TIA! -G







another (neat|strange)+ way I use the above is like so


.rowColor0 { background: #FF; }
.rowColor1,
.rowColor3 { background: #EE; }
.rowColor2 { background: #DD; }

'.$row.'';

}
?>



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







--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Re: Buffered Logging?

2009-08-10 Thread Waynn Lue
Thanks for all the help!  I'm going to try just writing to a database table
first with INSERT DELAYED, and if there ends up being a performance hit,
I'll use a MEMORY table that gets archived off every 5 minutes or so.

Waynn


Re: [PHP] Embedding foreach loops

2009-08-10 Thread hessiess
Do *NOT* get into the habit of outputting your HTML using echo or print
statements, it becomes unmaintainable very quickly, use a templating
language, ether with a framework(recomended) or standalone.

You should learn the basics of HTML and CSS, go and read
http://htmldog.com/, btw to add a newline you need to use "".

>> I am using the print function to display my html. I cannot get the
>> line return ( \n ) character to actually push the html onto the next
>> line, it just gets displayed instead. Should I be using echo?
>
>
> Allen, you off and running again?
>
> echo "blah..  \n"; //<-- this will print  the literal 'blah..  '  and
> then a newline into your HTML *source code*
> echo 'blah..  \n'; //<-- this will print the literal 'blah..  \n' into
> your HTML *source code*
>
> IIRC print is the same as echo.  That is not your apparent issue.
>
> Say if you are stuck again, and on what exactly.
>
> -John
>
> --
> 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] Radio buttons problem

2009-08-10 Thread leledumbo

> Unless, of course, what you have is
> 
>name[], email[], sex[0]
>name[], email[], sex[1]
>name[], email[], sex[2] 

Yep, that's exactly what I have.

> If it's important to you that the indexes match across name[], email[] and
> sex[], then you must supply
> them explicitly for every field in the group

I guess there's no other way than this, so OK I'll do it. Thanks.
-- 
View this message in context: 
http://www.nabble.com/Radio-buttons-problem-tp24786766p24912487.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] reason for a "Notice:.." on one site but not another? (Same code.)

2009-08-10 Thread Ashley Sheridan
On Mon, 2009-08-10 at 15:40 -0300, Martin Scotta wrote:
> This "intelligence" is given by the laziness of the && operator.
> 
> $res = a() && b(); # if a() is false then b() does not evaluate
> $res = a() & b(); # b() evaluates no matter a()'s result
> 
> so, order matters.
> 
> On Mon, Aug 10, 2009 at 3:29 PM, Andrew Ballard  wrote:
> 
> > On Mon, Aug 10, 2009 at 1:50 PM, Ralph Deffke
> > wrote:
> > > this is not "intelligence" its just pure math. the '&&' says if BOTH
> > > expressions are true then the whole expression is true.
> > >
> > > so if the first one is false, the whole is false, why checking the next
> > one
> > > in the underlaying C it would be something like this
> > > {
> > > if ( expression == false ) return false;
> > > if ( expression == false) return false;
> > > return true;
> > > }
> > >
> > > ralph
> > > ralph_def...@yahoo.de
> >
> > That's logically correct, and while PHP does implement this
> > "short-circuit" logic, not all languages do. In that regard, I
> > appreciate what John meant by saying it makes it look "more
> > intelligent." Some languages evaluate each of the conditions to their
> > respective boolean results before evaluating the logical operators.
> >
> > Andrew
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> 
You get the same thing in bash. You call a bunch of commands to run in
series, but the next one only runs if it's predecessor was successful.
It's frequent to see this sort of command chain:

./configure && make && make install

Thanks,
Ash
http://www.ashleysheridan.co.uk


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